Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from django.core.cache import cache
def cache_for(seconds,fetch=0):
def cache_it(func):
def deco_func(self):
val = cache.get(self.get_cache_key(fetch))
if not val:
val = func(self)
cache.set(self.get_cache_key(fetch), val, seconds)
return val
return deco_func
return cache_it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment