1 2 3 4 5 6 7 8 9 10 11 | from django.utils.hashcompat import md5_constructor
drop_chars = ''.join(['%c' % c for c in range(32)]) + ' '
def cache_key_clean(value):
"""
Make a key of the first up to 228 valid characters of the value,
appended with the md5 of the whole value.
"""
md5_hash = md5_constructor(value).hexdigest()
return ''.join([value.translate(None,drop_chars)[:228], md5_hash])
|
More like this
- Scoped Cache Compatible with Django Caching Helpers by axiak 5 years, 2 months ago
- template + cache = crazy delicious by jacobian 6 years ago
- CSV serializer by stringify 2 years, 6 months ago
- Validate request params without custom form by xiaoym 3 weeks, 4 days ago
- Language aware cache decorator by bartTC 4 years ago
Comments