~sirn/fanboi2

ref: 98796226802a26b82c888365ad5b9cd331006792 fanboi2/fanboi2/cache.py -rw-r--r-- 425 bytes
98796226Kridsada Thanabulpong Bump copyright year. 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import hashlib
import logging
from dogpile.cache import make_region


log = logging.getLogger(__name__)


def _key_mangler(key):
    """Retrieve cache keys as a long concatenated strings and turn them into
    an MD5 hash.

    :param key: A cache key :type:`str`.

    :type key: str
    :rtype: str
    """
    return hashlib.md5(bytes(key.encode('utf8'))).hexdigest()

cache_region = make_region(key_mangler=_key_mangler)