Restores locmem support for Django 1.6.

This commit is contained in:
Bertrand Bordage 2014-12-14 08:08:51 +01:00
parent 3e8135722a
commit b6c1dfc200
3 changed files with 23 additions and 23 deletions

View file

@ -32,6 +32,9 @@ before_script:
- mysql -u root -e 'CREATE DATABASE cachalot;'
script:
- CACHE_BACKEND=locmem DB_ENGINE=sqlite3 coverage run -a --source=cachalot ./runtests.py
- CACHE_BACKEND=locmem DB_ENGINE=postgresql coverage run -a --source=cachalot ./runtests.py
- CACHE_BACKEND=locmem DB_ENGINE=mysql coverage run -a --source=cachalot ./runtests.py
- CACHE_BACKEND=redis DB_ENGINE=sqlite3 coverage run -a --source=cachalot ./runtests.py
- CACHE_BACKEND=redis DB_ENGINE=postgresql coverage run -a --source=cachalot ./runtests.py
- CACHE_BACKEND=redis DB_ENGINE=mysql coverage run -a --source=cachalot ./runtests.py
@ -39,9 +42,6 @@ script:
- CACHE_BACKEND=memcached DB_ENGINE=postgresql coverage run -a --source=cachalot ./runtests.py
- CACHE_BACKEND=memcached DB_ENGINE=mysql coverage run -a --source=cachalot ./runtests.py
- if [[ $DJANGO == "Django>=1.7,<1.8" ]]; then
CACHE_BACKEND=locmem DB_ENGINE=sqlite3 coverage run -a --source=cachalot ./runtests.py;
CACHE_BACKEND=locmem DB_ENGINE=postgresql coverage run -a --source=cachalot ./runtests.py;
CACHE_BACKEND=locmem DB_ENGINE=mysql coverage run -a --source=cachalot ./runtests.py;
CACHE_BACKEND=filebased DB_ENGINE=sqlite3 coverage run -a --source=cachalot ./runtests.py;
CACHE_BACKEND=filebased DB_ENGINE=postgresql coverage run -a --source=cachalot ./runtests.py;
CACHE_BACKEND=filebased DB_ENGINE=mysql coverage run -a --source=cachalot ./runtests.py;

View file

@ -15,8 +15,7 @@ Requirements
- `filebased <https://docs.djangoproject.com/en/1.7/topics/cache/#filesystem-caching>`_
(only with Django >= 1.7 as it was not thread-safe before)
- `locmem <https://docs.djangoproject.com/en/1.7/topics/cache/#local-memory-caching>`_
(only with Django >= 1.7, and its also not shared between processes,
see :ref:`Limits`)
(but its not shared between processes, see :ref:`Limits`)
- one of these databases:

View file

@ -35,6 +35,17 @@ DATABASES['default'] = DATABASES.pop(os.environ.get('DB_ENGINE', 'sqlite3'))
CACHES = {
'locmem': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'OPTIONS': {
# We want that limit to be infinite, otherwise we cant
# reliably count the number of SQL queries executed in tests.
# In this context, 10e9 is enough to be considered
# infinite.
'MAX_ENTRIES': 10e9,
}
},
'redis': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://127.0.0.1:6379/0',
@ -51,23 +62,13 @@ CACHES = {
},
}
if django.VERSION >= (1, 7):
CACHES.update(
locmem={
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'OPTIONS': {
# We want that limit to be infinite, otherwise we cant
# reliably count the number of SQL queries executed in tests.
# In this context, 10e9 is enough to be considered infinite.
'MAX_ENTRIES': 10e9,
}
},
filebased={
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/tmp/django_cache',
'OPTIONS': {
'MAX_ENTRIES': 10e9, # (See locmem)
}
})
CACHES['filebased'] = {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/tmp/django_cache',
'OPTIONS': {
'MAX_ENTRIES': 10e9, # (See locmem)
}
}
try:
import pylibmc
except ImportError:
@ -78,7 +79,7 @@ if django.VERSION >= (1, 7):
'LOCATION': '127.0.0.1:11211',
}
DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'redis')
DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'locmem')
CACHES['default'] = CACHES.pop(DEFAULT_CACHE_ALIAS)
if DEFAULT_CACHE_ALIAS == 'memcached' and 'pylibmc' in CACHES:
del CACHES['pylibmc']