Django 1.6中的johnny cache 1.4不起作用?

时间:2014-08-19 02:33:22

标签: django memcached django-johnny-cache

我使用说明在Django 1.6中安装了johnny-cache 1.4但不起作用:

# add johnny's middleware
MIDDLEWARE_CLASSES = (
    'johnny.middleware.LocalStoreClearMiddleware',
    'johnny.middleware.QueryCacheMiddleware',
    # ...
)
# some johnny settings
CACHES = {
    'default' : dict(
        BACKEND = 'johnny.backends.memcached.MemcachedCache',
        LOCATION = ['127.0.0.1:11211'],
        JOHNNY_CACHE = True,
    )
}
JOHNNY_MIDDLEWARE_KEY_PREFIX='jc_myproj'

出现的错误是:

$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/diegoug/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 6, in <module>
    from django.contrib.staticfiles.handlers import StaticFilesHandler
  File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 8, in <module>
    from django.contrib.staticfiles.views import serve
  File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/views.py", line 15, in <module>
    from django.contrib.staticfiles import finders
  File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 12, in <module>
    from django.contrib.staticfiles.storage import AppStaticStorage
  File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 8, in <module>
    from django.core.cache import (get_cache, InvalidCacheBackendError,
  File "/home/diegoug/local/lib/python2.7/site-packages/django/core/cache/__init__.py", line 138, in <module>
    cache = get_cache(DEFAULT_CACHE_ALIAS)
  File "/home/diegoug/local/lib/python2.7/site-packages/django/core/cache/__init__.py", line 130, in get_cache
    "Could not find backend '%s': %s" % (backend, e))
django.core.cache.backends.base.InvalidCacheBackendError: Could not find backend 'johnny.backends.memcached.MemcachedCache': 'module' object has no attribute 'CacheClass'

调查并说问题更多的是Django,我想解决它,因为这是一个很棒的工具,它会有很大的帮助。

1 个答案:

答案 0 :(得分:1)

升级到今天更新的Django 1.7版,继续出现同样的问题,我做的是升级到版本johnny缓存开发:

johnny-cache==1.6.1a
python-memcached==1.53

有了这个,我暂时解决了这个问题,直到他们更新