From 43b29a9271da0c8cebe51e18f7bf72284c003cb3 Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Sun, 14 Dec 2014 05:57:40 +0100 Subject: [PATCH] Removes locmem support on Django 1.6. --- .travis.yml | 8 ++++---- docs/quickstart.rst | 3 ++- settings.py | 35 ++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6eefe72..9f89d11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,9 +32,6 @@ 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 @@ -42,6 +39,9 @@ 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; @@ -57,4 +57,4 @@ after_success: coveralls matrix: exclude: - python: 2.6 - env: DJANGO=">=1.7,<1.8" + env: DJANGO="Django>=1.7,<1.8" diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 7ffb7f3..00ba02d 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -14,7 +14,8 @@ Requirements - `filebased `_ (only with Django >= 1.7 as it was not thread-safe before) - `locmem `_ - (but it’s not shared between processes, see :ref:`Limits`) + (only with Django >= 1.7, and it’s also not shared between processes, + see :ref:`Limits`) - one of these databases: diff --git a/settings.py b/settings.py index de47631..af81b63 100644 --- a/settings.py +++ b/settings.py @@ -35,15 +35,6 @@ 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 can’t - # 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', @@ -60,13 +51,23 @@ CACHES = { }, } if django.VERSION >= (1, 7): - CACHES['filebased'] = { - 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', - 'LOCATION': '/tmp/django_cache', - 'OPTIONS': { - 'MAX_ENTRIES': 10e9, # (See locmem) - } - } + CACHES.update( + locmem={ + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'OPTIONS': { + # We want that limit to be infinite, otherwise we can’t + # 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) + } + }) try: import pylibmc except ImportError: @@ -77,7 +78,7 @@ else: 'LOCATION': '127.0.0.1:11211', } -DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'locmem') +DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'redis') CACHES['default'] = CACHES.pop(DEFAULT_CACHE_ALIAS) if DEFAULT_CACHE_ALIAS == 'memcached' and 'pylibmc' in CACHES: del CACHES['pylibmc']