Django Cache cache.set Not storing data
Make sure it's using the correct cache. Try from django.core.cache import caches
, and then see the contents of caches.all()
. It should just have one instance of django.core.cache.backends.memcached.MemcachedCache
.
If it is, try accessing that directly, e.g.
from django.core.cache import caches m_cache = caches.all()[0]m_cache.set("stack","overflow",3000)m_cache.get("stack")
This might not solve your problem, but will at least get you closer to debugging Memcached instead of Django's cache proxy or your configuration.
I believe django augments the key with a version. For example,
django_memcache.set('my_key', 'django', 1000)
will set the key :1:my_key
in memcache:
<36 set :1:my_key 0 1000 6>36 STORED
However, if you set the key through telnet or python-memcached module, it will store the raw key as expected:
<38 set my_key 0 1000 13 >38 STORED
So, perhaps you are not querying the correct key?
See https://docs.djangoproject.com/en/1.10/topics/cache/#cache-key-transformation