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

posted on 2020-05-19 20:01  Go_Forward  阅读(241)  评论(0编辑  收藏  举报