Question: 我无法获得memcached
正在听UDP
, 上班 (get
set
delete
)与姜戈。
我只让 memcached 监听UDP
11211
,正如我在上一个问题 https://stackoverflow.com/questions/36055900/get-set-memcached-listening-on-udp-using-python。到目前为止我已经尝试过:
1.设置CACHES
to use python-memcached
Python 绑定。 get 和 set 不适用于简单的设置,即'LOCATION': '127.0.0.1:11211'
,所以尝试指定udp
明确地(使用这个mention http://sendapatch.se/projects/pylibmc/reference.html#pylibmc.Client作为理由):
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'udp:127.0.0.1:11211',
'TIMEOUT': None,
}
}
gave:
ValueError: Unable to parse connection string: "udp:localhost:11211"
2.设置CACHES
to use pylibmc
Python 绑定:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': 'udp:127.0.0.1:11211',
'TIMEOUT': None,
}
}
服务器运行良好 - 进一步验证:
>>> import django
>>> from django.core.cache import cache
>>> cache.set('udp_key', 12)
>>> cache.get('udp_key')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 84, in get
val = self._cache.get(key)
NotSupportedError: error 28 from memcached_get(:1:udp_key): ACTION NOT SUPPORTED
P.S.不要将其设置为 memcachedTCP
vs UDP
debate
类似的问题——get() set() memcached 使用 Python 监听 UDP https://stackoverflow.com/questions/36055900/get-set-memcached-listening-on-udp-using-python