Tools version:
Memcached is currently running:
$ ps -ef | grep memcache
nobody 2993 1 0 16:46 ? 00:00:00 /usr/bin/memcached -m 64 -p 11211 -u nobody -l 127.0.0.1
I'm using memcached and python memcached with my Django proj and I've set it like the following in settings.py
:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'TIMEOUT': 86400,
},
}
I've set the cache in the code:
from django.core.cache import cache
cache.set('countries', ['Canada', 'US'])
I then open a Django shell to inspect the content of the cache:
>>> from django.core.cache import cache
>>> 'countries' in cache
True
>>> import memcache
>>> mc = memcache.Client(['127.0.0.1:11211'], debug=1)
>>> mc.get('countries')
>>>
When I use Django's cache, countries
key exists. However, when I use Python's memcache, I don't get anything for countries. What am I doing wrong above?
Django prefixes cache keys with a colon. You can inspect memcached like so if this doesn't help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With