1 2 3 4 5 6 7 8 9 | from django.core.cache import cache
from django.utils.hashcompat import md5_constructor
from django.utils.http import urlquote
from functional import compose
def invalidate_template_cache(fragment_name, *variables):
args = md5_constructor(u':'.join(apply(compose(urlquote, unicode), variables)))
cache_key = 'template.cache.%s.%s' % (fragment_name, args.hexdigest())
cache.delete(cache_key)
|
More like this
- Safer cache key generation by cmheisel 3 years, 5 months ago
- Language aware cache decorator by bartTC 3 years ago
- Binding signals to abstract models by andreterra 5 days, 20 hours ago
- Scalable and invalidateble cache_page decorator by marinho 3 years ago
- Model manager with row caching by jobs@flowgram.com 3 years, 11 months ago
Comments
ah, my bad... "functional" is http://oakwinter.com/code/functional/
For completeness sake:
#
This didn't work for me on django1.1,
The following did though:
#
https://github.com/tedtieken/django-template-reset-cache
Wraps the invalidation function in a template tag.
#