Reputation: 313
I installed them both, but i get a None every time i try to get some key
>>from django.core.cache import cache #no errors
>>cache.set('value1','value2',39) #no errors
>>cache.get('value1') #no errors but no value either
in settings.py i got
CACHES = {
'default':{
'BACKEND':'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION':'127.0.0.1:1991',
'TIMEOUT': 1200,
}
}
what is going on wrong? I don't have even the slightest idea what to debug or where to start ...
Upvotes: 0
Views: 1470
Reputation: 87134
Are you sure that memcached is actually running, and that it is configured to listen on 127.0.0.1 port 1991? By default memcached listens on port 11211.
django.core.cache.cache
plays dumb when memcache
fails to store keys, it doesn't raise an exception or return any error.
You can test more directly with memcache like this:
import memcache
for port in (1991, 11211):
print "Testing memcached on port %d" % port
mc = memcache.Client(['127.0.0.1:%d' % port])
if mc.set('value1', 'value2'):
print "stored key value pair"
if mc.get('value1') == 'value2':
print "successfully retrieved value"
break
else:
print "Failed to retrieve value"
else:
print "Failed to store key value pair"
Upvotes: 1