Question: I am not able to get memcached
listening on UDP
, to work (get
set
delete
) with Django.
I have the memcached listening only on UDP
11211
, as I have mentioned in the previous question. What I have tried so far:
1.Setting CACHES
to use python-memcached
Python binding. get and set didn't work with simple settings i.e. 'LOCATION': '127.0.0.1:11211'
, so tried specifying udp
explicitly (using this mention as the rationale):
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.Setting CACHES
to use pylibmc
Python binding:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': 'udp:127.0.0.1:11211',
'TIMEOUT': None,
}
}
The server ran fine - to further verify:
>>> 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. Don't make it a memcached on TCP
vs UDP
debate
A similar question - get() set() memcached listening on UDP using Python