2013-02-24 19:58:02 +08:00
|
|
|
import hashlib
|
2015-01-28 20:35:27 +08:00
|
|
|
|
2013-02-24 19:58:02 +08:00
|
|
|
TEMPLATE_FRAGMENT_KEY_TEMPLATE = 'template.cache.%s.%s'
|
|
|
|
|
|
|
|
|
|
|
|
def make_template_fragment_key(fragment_name, vary_on=None):
|
2019-09-12 05:12:35 +08:00
|
|
|
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())
|