缓存视图函数
使用装饰器 cached()
能够缓存视图函数。它在默认情况下使用请求路径(request.path)作为cache_key:
@cache.cached(timeout=50)
def index():
return render_template('index.html')
该装饰器有一个可选的参数:unless
,它允许一个可调用的、返回值是True或者False的函数。如果 unless
返回 True
,将会完全忽略缓存机制(内置的缓存机制会完全不起作用)。
当前内容版权归 wizardforcel 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 wizardforcel .