4

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
4

2 に答える 2

7

構成に問題があったと思うので、MacPorts を使用して Memcache を再度インストールしました

$ sudo port install memcached 

Memcache を実行したところ、動作しました

$ memcached -vv

これらの手順は、Mac OS X 10.7.5 (Lion) でテストされています。

詳細については、このウェブサイトをご覧ください

于 2013-08-22T16:44:38.043 に答える
4

ありがとう、それがubuntuマシンでもうまくいったことを付け加えたいだけです...

ubuntu にインストールするには:

$sudo apt-get install memcached
于 2014-05-26T07:29:19.827 に答える