Created
September 3, 2010 20:56
-
-
Save lvidarte/564547 to your computer and use it in GitHub Desktop.
Django cache_timeout decorator
This file contains hidden or 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
def cache_timeout(timeout): | |
def cache(view): | |
def deco(*args, **kwargs): | |
response = view(*args, **kwargs) | |
response.cache_timeout = timeout | |
return response | |
return deco | |
return cache | |
# #Example | |
# @cache_timeout(60*60) | |
# def index(request): | |
# title = "Hello world" | |
# return render_to_response('index.html', locals()) | |
# #index = cache_timeout(60*60)(index)(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment