I am trying to use Memcache in my Django app, but it seems that something in my configuration is missing. Any help would be appreciated, Thank you!
$ python manage.py shell
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.cache import cache
>>> cache.set('my_key', 'hello, world!', 30)
>>> print cache.get('my_key')
None
>>>
Settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
APIs installed:
$ pypm install python-memcached
$ brew install memcached
$ brew install libmemcached
'LOCATION': '127.0.0.1:8000'this is supposed to be location of memcached, not Djangotelnet localhost 11211if you getConnection refusedyour memcached is not running. If you get telnet prompt, typestats. You should get bunch of memcached's stats, if you don't your memcache isn't configured properly