Upgrade django-cache-machine to 0.8 (bug 883477)

count()s caching is disabled in tests, this was already done before
by accident, this is now done on purpose because it messes up with
all the tests.
This commit is contained in:
Mathieu Pillard 2013-10-01 17:56:32 -04:00
Родитель 45b94603cf
Коммит 85eb804db8
14 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -18,6 +18,7 @@ from django.http import SimpleCookie
from django.test.client import Client
from django.utils import translation
import caching
import elasticutils.contrib.django as elasticutils
import mock
import pyelasticsearch.exceptions as pyelasticsearch
@ -275,6 +276,9 @@ class TestCase(MockEsMixin, RedisTest, test_utils.TestCase):
def _pre_setup(self):
super(TestCase, self)._pre_setup()
cache.clear()
# Override django-cache-machine caching.base.TIMEOUT because it's
# computed too early, before settings_test.py is imported.
caching.base.TIMEOUT = settings.CACHE_COUNT_TIMEOUT
@contextmanager
def activate(self, locale=None, app=None):

Просмотреть файл

@ -56,13 +56,13 @@ class Translation(amo.models.ModelBase):
@property
def cache_key(self):
return self._cache_key(self.id)
return self._cache_key(self.id, self._state.db)
@classmethod
def _cache_key(cls, pk):
def _cache_key(cls, pk, db):
# Hard-coding the class name here so that subclasses don't try to cache
# themselves under something like "o:translations.purifiedtranslation".
key_parts = ('o', 'translations.translation', pk)
key_parts = ('o', 'translations.translation', pk, db)
return ':'.join(map(encoding.smart_unicode, key_parts))
@classmethod

Просмотреть файл

@ -31,7 +31,7 @@ SLAVE_DATABASES = ['slave']
# Use IP:PORT pairs separated by semicolons.
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
'LOCATION': ['localhost:11211', 'localhost:11212'],
'TIMEOUT': 500,
}

Просмотреть файл

@ -43,7 +43,7 @@ We slipped this in with the basic install. The package was
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
'LOCATION': ['localhost:11211'],
'TIMEOUT': 500,
}

Просмотреть файл

@ -17,7 +17,7 @@ Django==1.4.8
dj-database-url==0.2.2
django-aesfield==0.1
django-browserid==0.8
django-cache-machine==0.6
django-cache-machine==0.8
django-celery==3.0.17
django-cronjobs==0.2.3
django_csp==1.0.2

Просмотреть файл

@ -80,7 +80,7 @@ DATABASES['default']['TEST_CHARSET'] = 'utf8'
DATABASES['default']['TEST_COLLATION'] = 'utf8_general_ci'
CACHES = {
'default': {
'BACKEND': 'caching.backends.locmem.CacheClass',
'BACKEND': 'caching.backends.locmem.LocMemCache',
}
}
CELERY_ALWAYS_EAGER = True

Просмотреть файл

@ -70,7 +70,7 @@ DATABASES = {
CACHES = {
'default': {
'BACKEND': 'caching.backends.locmem.CacheClass',
'BACKEND': 'caching.backends.locmem.LocMemCache',
}
}
CELERY_ALWAYS_EAGER = True

Просмотреть файл

@ -75,7 +75,7 @@ DATABASES['default']['TEST_CHARSET'] = 'utf8'
DATABASES['default']['TEST_COLLATION'] = 'utf8_general_ci'
CACHES = {
'default': {
'BACKEND': 'caching.backends.locmem.CacheClass',
'BACKEND': 'caching.backends.locmem.LocMemCache',
}
}
CELERY_ALWAYS_EAGER = True

Просмотреть файл

@ -71,10 +71,14 @@ USERPICS_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.png?modified=%d'
CACHES = {
'default': {
'BACKEND': 'caching.backends.locmem.CacheClass',
'BACKEND': 'caching.backends.locmem.LocMemCache',
}
}
# COUNT() caching can't be invalidated, it just expires after x seconds. This
# is just too annoying for tests, so disable it.
CACHE_COUNT_TIMEOUT = None
# No more failures!
APP_PREVIEW = False

Просмотреть файл

@ -46,7 +46,7 @@ SLAVE_DATABASES = ['slave']
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
# 'BACKEND': 'memcachepool.cache.UMemcacheCache',
'LOCATION': splitstrip(private.CACHES_DEFAULT_LOCATION),

Просмотреть файл

@ -47,7 +47,7 @@ SLAVE_DATABASES = ['slave']
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
'LOCATION': splitstrip(private.CACHES_DEFAULT_LOCATION),
'TIMEOUT': 500,
'KEY_PREFIX': CACHE_PREFIX,

Просмотреть файл

@ -46,7 +46,7 @@ SLAVE_DATABASES = ['slave']
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
# 'BACKEND': 'memcachepool.cache.UMemcacheCache',
'LOCATION': splitstrip(private.CACHES_DEFAULT_LOCATION),

Просмотреть файл

@ -37,7 +37,7 @@ SLAVE_DATABASES = ['slave']
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
'LOCATION': splitstrip(private.CACHES_DEFAULT_LOCATION),
'TIMEOUT': 500,
'KEY_PREFIX': CACHE_PREFIX,

Просмотреть файл

@ -44,7 +44,7 @@ SLAVE_DATABASES = ['slave']
CACHES = {
'default': {
'BACKEND': 'caching.backends.memcached.CacheClass',
'BACKEND': 'caching.backends.memcached.MemcachedCache',
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
# 'BACKEND': 'memcachepool.cache.UMemcacheCache',
'LOCATION': splitstrip(private.CACHES_DEFAULT_LOCATION),