我正在尝试在我的 Django 应用程序中使用 Memcache,但似乎我的配置中缺少某些内容。任何帮助将不胜感激,谢谢!
$ 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
>>>
设置.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
已安装的 API:
$ pypm install python-memcached
$ brew install memcached
$ brew install libmemcached