Exemple #1
0
def delete_course_memcached(id):
    """
    删除特定课程的缓存(课程被删除后自动执行)
    """
    course = Courses.query.get_or_404(id)
    lru.delete(course)
    lru.save()
Exemple #2
0
def delete_course_memcached(id):
    """
    删除特定课程的缓存(课程被删除后自动执行)
    """
    course = Courses.query.get_or_404(id)
    lru.delete(course)
    lru.save()
Exemple #3
0
def update_course_memcached(id):
    """
    更新特定id课程的缓存
    """
    course = Courses.query.get_or_404(id)
    lru.delete(course)
    lru.set(course.to_json(), [course.name, course.teacher])
    lru.save()
Exemple #4
0
def update_course_memcached(id):
    """
    更新特定id课程的缓存
    """
    course = Courses.query.get_or_404(id)
    lru.delete(course)
    lru.set(course.to_json(), [course.name, course.teacher])
    lru.save()
Exemple #5
0
def read_data2_memcached():
    """
    将postgresql数据库中的课程搜索数据
    读入LRU并写入硬盘(数据库读取开销)
    """
    courses = Courses.query.all()
    for course in courses:
        lru.set(course.to_json(), [course.name, course.teacher])
    lru.save()  # 数据存储硬盘
Exemple #6
0
def delete_course(id):
    course = Courses.query.get_or_404(id)
    if request.method == "DELETE":
        db.session.delete(course)
        db.session.commit()
        # 自动清除缓存
        lru.delete(course)
        lru.save()
        return jsonify({"message": "该课程已被删除"})
Exemple #7
0
def delete_course(id):
    course = Courses.query.get_or_404(id)
    if request.method == "DELETE":
        db.session.delete(course)
        db.session.commit()
        # 自动清除缓存
        lru.delete(course)
        lru.save()
        return jsonify({'message': '该课程已被删除'})
Exemple #8
0
def read_data2_memcached():
    """
    将postgresql数据库中的课程搜索数据
    读入LRU并写入硬盘(数据库读取开销)
    """
    courses = Courses.query.all()
    for course in courses:
        lru.set(course.to_json(), [course.name, course.teacher])
    lru.save()  # 数据存储硬盘