Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment