1# -*- coding: utf-8 -*- 2from __future__ import absolute_import 3import datetime 4from hashlib import sha1 5 6from dogpile.cache import make_region 7 8#: Expiration time for show caching 9SHOW_EXPIRATION_TIME = datetime.timedelta(weeks=3).total_seconds() 10 11#: Expiration time for episode caching 12EPISODE_EXPIRATION_TIME = datetime.timedelta(days=3).total_seconds() 13 14#: Expiration time for scraper searches 15REFINER_EXPIRATION_TIME = datetime.timedelta(weeks=1).total_seconds() 16 17 18def sha1_key_mangler(key): 19 """Return sha1 hex for cache keys""" 20 if isinstance(key, str): 21 key = key.encode("utf-8") 22 23 return sha1(key).hexdigest() 24 25 26# Use key mangler to limit cache key names to 40 characters 27region = make_region(key_mangler=sha1_key_mangler) 28