~sirn/fanboi2

ref: c1f8e48d5062ca982c7bd9392477a4cc8623d32e fanboi2/fanboi2/cache.py -rw-r--r-- 425 bytes
c1f8e48dKridsada Thanabulpong Fix GeoIP2 raising no method error. 5 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)