1 2 3 4 5 6 7 8 | def cache_result(callable, cache_key, timeout):
def inner(*args, **kwargs):
result = cache.get(cache_key)
if result is None:
result = callable(*args, **kwargs)
cache.set(cache_key, result, timeout)
return result
return inner
|
More like this
- per-function cache decorator by nicois 4 years ago
- Stales Cache Class Method Decorator by amitu 3 years, 3 months ago
- Cache decorator by xyb 4 years, 2 months ago
- Language aware cache decorator by bartTC 2 years, 9 months ago
- New view decorator to only cache pages for anonymous users by vaughnkoch 1 year, 4 months ago
Comments