Created
July 24, 2010 20:30
-
-
Save lprsd/488946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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