Cache Decorator

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

  1. Conditional cache decorator by alexisbellido 9 months ago
  2. Stales Cache Class Method Decorator by amitu 4 years, 7 months ago
  3. django ajax_view decorator by chizcracker 1 year ago
  4. Method Caching by bryanhelmig 1 year, 10 months ago
  5. Searching and Deleting Cache Entries in Admin tool by shootclub 1 year, 10 months ago

Comments

(Forgotten your password?)