【问题标题】:johnny cache 1.4 in Django 1.6 does not work?Django 1.6 中的 johnny cache 1.4 不起作用?
【发布时间】:2014-08-19 02:33:21
【问题描述】:

我使用说明在 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,我想修复它,因为这是一个很棒的工具,它会很有帮助。

【问题讨论】:

  • 您是否安装并运行了 memcache?
  • 同样的问题,我在互联网上都看到了。 johnny cache 更新已经 3 个月了,可能这个项目已经泡汤了。

标签: django memcached django-johnny-cache


【解决方案1】:

升级到今天更新的Django 1.7版,继续同样的问题,我所做的是升级到版本johnny cache development:

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

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

【讨论】:

  • 不要使用 johnny-cache 1.6.1a,它被 Django 1.6 破坏了。测试通过了,但这并不意味着测试是正确的。
  • Johnny-cache 变得一团糟,改用django-cachalot。我试图修复 johnny-cache,但最终重写了一个新项目……
猜你喜欢
  • 2012-06-12
  • 1970-01-01
  • 2012-12-05
  • 2014-01-10
  • 1970-01-01
  • 2014-04-11
  • 1970-01-01
  • 1970-01-01
  • 2015-03-23
相关资源
最近更新 更多