【问题标题】:What are the correct steps to set up django-cache-machine?设置 django-cache-machine 的正确步骤是什么?
【发布时间】:2014-10-02 03:29:22
【问题描述】:

我是 Django 和缓存新手,正在使用 Django 1.6。

我按照 django-cache-machine' 页面上的说明进行安装。

1.pip 安装 django-cache-machine

2.在settings.py中添加以下内容

CACHES = {
    'default': {
        'BACKEND': 'caching.backends.memcached.MemcachedCache',
        'LOCATION': 'localhost:11211',
        'PREFIX': 'wee:',
    },
}

3.将更改应用到我的一个模型上,就像说明中的最小情况一样。

当我尝试运行服务器时,它显示以下错误。

django.core.cache.backends.base.InvalidCacheBackendError: 不能 找到后端 'caching.backends.memcached.MemcachedCache': 'module' 对象没有属性“CacheClass”

我之前安装了 johnny-cache 但很快将其删除,然后安装了缓存机器。我不知道这是否相关。 Memcached 也在运行。

提前致谢!

编辑:

刚刚发现应用的Github页面的一期已经提到了。 https://github.com/jbalogh/django-cache-machine/issues/44

并进行了修复。所以我重新安装了 github 版本。

pip install -e git://github.com/jbalogh/django-cache-machine.git#egg=django-cache-machine

现在它显示另一个错误。

ImportError: No module named memcache

所以我安装了另一个名为 python-memcached 的应用程序。服务器运行,但没有发生缓存。

我运行 python shell 并且应用程序运行良好。所以我认为问题仍然是 django-cache-machine。

我猜 django-cache-machine 还没有完全支持 Django 1.6。

如果有人知道如何让它在 Django 1.6+Python 2.7 上运行,请告诉我。

再次感谢!

【问题讨论】:

标签: python django caching django-cache-machine


【解决方案1】:

只需安装 memcach:

  pip install python-memcached

这为我解决了问题!

【讨论】:

    猜你喜欢
    • 2021-09-30
    • 1970-01-01
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 2020-05-07
    • 2013-12-26
    • 2014-03-16
    • 2012-04-23
    相关资源
    最近更新 更多