|
|
@ -92,14 +92,14 @@ class ApplicationCache():
|
|
|
|
|
|
|
|
|
|
|
|
def cache_anything(self, key_prefix: str = None, max_age: int = None, packer = IDENTITY, unpacker = IDENTITY):
|
|
|
|
def cache_anything(self, key_prefix: str = None, max_age: int = None, packer = IDENTITY, unpacker = IDENTITY):
|
|
|
|
def decorator(fun):
|
|
|
|
def decorator(fun):
|
|
|
|
key_prefix = key_prefix or fun.__name__
|
|
|
|
cache_prefix = key_prefix or fun.__name__
|
|
|
|
@wraps(fun)
|
|
|
|
@wraps(fun)
|
|
|
|
def decorated(*args, no_cache: bool = False, cache_no_lookup: bool = False, cache_no_store: bool = False, **kwargs):
|
|
|
|
def decorated(*args, no_cache: bool = False, cache_no_lookup: bool = False, cache_no_store: bool = False, **kwargs):
|
|
|
|
cache_no_lookup = no_cache or cache_no_lookup
|
|
|
|
cache_no_lookup = no_cache or cache_no_lookup
|
|
|
|
cache_no_store = no_cache or cache_no_store
|
|
|
|
cache_no_store = no_cache or cache_no_store
|
|
|
|
no_cache_key = cache_no_lookup and cache_no_store
|
|
|
|
no_cache_key = cache_no_lookup and cache_no_store
|
|
|
|
if not no_cache_key:
|
|
|
|
if not no_cache_key:
|
|
|
|
cache_key = self.gen_key(key_prefix, args, kwargs)
|
|
|
|
cache_key = self.gen_key(cache_prefix, args, kwargs)
|
|
|
|
if not cache_no_lookup:
|
|
|
|
if not cache_no_lookup:
|
|
|
|
cached_data = self.load(key=cache_key, max_age=max_age)
|
|
|
|
cached_data = self.load(key=cache_key, max_age=max_age)
|
|
|
|
if cached_data is not None:
|
|
|
|
if cached_data is not None:
|
|
|
|