24

Flask-Restful で Flask-Cache @cache.cached() デコレータを使用するにはどうすればよいですか? たとえば、Resource から継承されたクラス Foo があり、Foo には get、post、put、および delete メソッドがあります。

の後にキャッシュされた結果を無効にするにはどうすればよいPOSTですか?

@api.resource('/whatever')
class Foo(Resource):
    @cache.cached(timeout=10)
    def get(self):
        return expensive_db_operation()

    def post(self):
        update_db_here()

        ## How do I invalidate the value cached in get()?
        return something_useful()
4

5 に答える 5

3

はい、そのように使用できます。

多分あなたはまだ読む必要があるでしょう:フラスコキャッシュメモ化URLクエリ文字列パラメータも

于 2015-06-17T12:30:53.480 に答える
1

You can invalidate cache using cache.clear() method.
For more detials see: https://pythonhosted.org/Flask-Cache/#flask.ext.cache.Cache.clear and Clearing Cache section in https://pythonhosted.org/Flask-Cache/

于 2016-08-08T15:55:27.800 に答える