Pom*_*eyo 4 python django memcached
我正在尝试在我的 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
>>>
Run Code Online (Sandbox Code Playgroud)
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
Run Code Online (Sandbox Code Playgroud)
$ pypm install python-memcached
$ brew install memcached
$ brew install libmemcached
Run Code Online (Sandbox Code Playgroud)
我想我的配置有一些问题,所以我只是使用 MacPorts 再次安装了 Memcache
$ sudo port install memcached
Run Code Online (Sandbox Code Playgroud)
然后我运行了 Memcache,它工作正常
$ memcached -vv
Run Code Online (Sandbox Code Playgroud)
这些指令已经在 Mac OS X 10.7.5 (Lion) 上测试过
欲了解更多信息,请访问此网站