16 lines
362 B
Python
Raw Normal View History

2025-02-22 13:06:06 +08:00
from .instances import cache
def from_cache(key):
def decorator(func):
def wrapper(*args, **kwargs):
cached = cache.get(key)
if cached:
return cached
else:
result = func(*args, **kwargs)
cache.set(key, result)
return result
return wrapper