python – cache.get(‘key’)在Django中使用Memcached返回None
发布时间:2020-12-20 11:29:13 所属栏目:Python 来源:网络整理
导读:我试图在我的Django应用程序中使用Memcache,但似乎我的配置中缺少某些内容. 任何帮助将不胜感激,谢谢! $python manage.py shellPython 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
我试图在我的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 >>> Settings.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 解决方法
我认为我的配置存在一些问题,所以我刚刚使用MacPorts安装了Memcache
$sudo port install memcached 然后我运行Memcache,它的工作原理 $memcached -vv 这些说明已在Mac OS X 10.7.5(Lion)上测试过 有关更多信息visit this website (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |