Skip to content

Instantly share code, notes, and snippets.

@lprsd
Created July 24, 2010 20:30
Show Gist options
  • Save lprsd/488946 to your computer and use it in GitHub Desktop.
Save lprsd/488946 to your computer and use it in GitHub Desktop.
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