【发布时间】:2017-07-15 09:31:59
【问题描述】:
我正在使用 using 为我的网站使用缓存。这给出了以下错误:
"Control/space characters not allowed (key="\xebw\x1b}\xae\xa3\xb8\x18\xc4\xb5\xce\x0c%\x13'\xed")".
我使用的代码如下:
def hash_key(key, key_prefix, version):
new_key = '%s :%s :%s' % (key_prefix, version, key)
if len(new_key) > 250:
m = hashlib.md5()
m.update(new_key)
new_key = m.digest()
return new_key
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1.11211',
'KEY_FUNCTION': hash_key,
}
}
【问题讨论】:
-
欢迎来到本站!如果您还没有,请查看tour 和how to ask page,了解更多关于以吸引高质量答案的方式提出问题的信息。
标签: python django memcached hash-function