1
0
mirror of https://github.com/django/django.git synced 2025-04-01 03:56:42 +00:00
django/django/core/cache/utils.py
Daniel Fairhead 5cb3ed187b Fixed #30772 -- Optimized make_template_fragment_key().
Removed usage of urllib.quote(), unnecessary since cbbe60c7fc39fa8ff75554bd90104eaad6924bb1.
Used hasher's .update() on key fragments.
2019-09-18 14:53:05 +02:00

13 lines
375 B
Python

import hashlib
TEMPLATE_FRAGMENT_KEY_TEMPLATE = 'template.cache.%s.%s'
def make_template_fragment_key(fragment_name, vary_on=None):
hasher = hashlib.md5()
if vary_on is not None:
for arg in vary_on:
hasher.update(str(arg).encode())
hasher.update(b':')
return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, hasher.hexdigest())