flask cache

http://brunorocha.org/python/flask/using-flask-cache.html

如何在大项目中使用cache

新建全局cache.py

cache = Cache(config={"CACHE_TYPE": "filesystem", "CACHE_DIR": "/tmp", "CACHE_THRESHOLD": "3000"})

在views.py 中导入

from airflow.cache import cache

@cache.cached(timeout=2, key_prefix=make_cache_key)

@expose("/test")

def test():

    return 1

在app中导入

from airflow.cache import cache

cache.init_app(app)

https://stackoverflow.com/questions/9413566/flask-cache-memoize-url-query-string-parameters-as-well  # more important

https://stackoverflow.com/questions/42721927/flask-cache-memoize-not-working-with-flask-restful-resources

猜你喜欢

转载自www.cnblogs.com/buxizhizhoum/p/12919119.html