【问题标题】:Johnny Cache with template caching带有模板缓存的 Johnny Cache
【发布时间】:2013-11-08 18:20:51
【问题描述】:

我正在使用 Django 1.4 设置 Johnny Cache 和模板缓存。我们当前的设置如下所示:

# Django Cache
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '192.168.100.1:11211',
    }
}

# JohnnyCache
JOHNNY_CACHE_BACKEND = "memcached://192.168.100.1:11211/"
MAN_IN_BLACKLIST = ('django_session',...)

JOHNNY_CACHE_BACKEND 已被弃用,因此我们需要将 johnny 设置移动到缓存字典中。 Per the documenataion,这似乎很容易。但是,我们的模板缓存会发生什么?这些设置是否像这样并存?

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '192.168.100.1:11211',
    }
    'default' : dict(
        BACKEND = 'johnny.backends.memcached.MemcachedCache',
        LOCATION = ['192.168.100.1:11211'],
        JOHNNY_CACHE = True,
    )
}

或者 johnny.backends.memcached.MemcachedCache 是 django.core.cache.backends.memcached.MemcachedCache 的替代品,在这种情况下我们应该有这个:

CACHES = {
    'default' : dict(
        BACKEND = 'johnny.backends.memcached.MemcachedCache',
        LOCATION = ['192.168.100.1:11211'],
        JOHNNY_CACHE = True,
    )
}

它将处理查询和模板缓存。任何见解将不胜感激。

【问题讨论】:

    标签: django caching django-johnny-cache


    【解决方案1】:

    来自 Jason Moiron ‏@jmoiron(Johnny Cache 的创建者)通过 Twitter:

    这是一个直接的替换,唯一的区别是它对 0 的处理(johnny 的 0 = inf,django 的 0 是即时超时)

    【讨论】:

      猜你喜欢
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-14
      • 1970-01-01
      • 1970-01-01
      • 2016-01-30
      相关资源
      最近更新 更多