清除缓存

请参看 clear().

下面的例子是一个用来清空应用缓存的脚本:

  1. from flask.ext.cache import Cache
  2. from yourapp import app, your_cache_config
  3. cache = Cache()
  4. def main():
  5. cache.init_app(app, config=your_cache_config)
  6. with app.app_context():
  7. cache.clear()
  8. if __name__ == '__main__':
  9. main()

Warning

某些缓存类型不支持完全清空缓存。同样,如果你不使用键前缀,一些缓存类型将刷新整个数据库。请确保你没有任何其他数据存储在缓存数据库中。