Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for testing against the builtin redis backend #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cachalot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'django.core.cache.backends.dummy.DummyCache',
'django.core.cache.backends.locmem.LocMemCache',
'django.core.cache.backends.filebased.FileBasedCache',
'django.core.cache.backends.redis.RedisCache',
'django_redis.cache.RedisCache',
'django.core.cache.backends.memcached.MemcachedCache',
'django.core.cache.backends.memcached.PyLibMCCache',
Expand Down
2 changes: 2 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Requirements
- a cache configured as ``'default'`` with one of these backends:

- `django-redis <https://github.com/niwinz/django-redis>`_
- `redis <https://docs.djangoproject.com/en/dev/topics/cache/#redis>`_
(requires Django >= 4)
- `memcached <https://docs.djangoproject.com/en/dev/topics/cache/#memcached>`_
(using either python-memcached or pylibmc)
- `filebased <https://docs.djangoproject.com/en/dev/topics/cache/#filesystem-caching>`_
Expand Down
12 changes: 12 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@
}
}

try:
from django.core.cache.backends.redis import RedisCache
except ImportError:
pass
else:
CACHES['builtin_redis']= {
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
# Make sure to use a different redis database to avoid conflicts with the other
# redis cache backend.
'LOCATION': 'redis://127.0.0.1:6379/1',
}

try:
import pylibmc
except ImportError:
Expand Down
25 changes: 13 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tox]
envlist =
py{37,38,39,310}-django3.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{38,39,310}-django4.1-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{38,39,310,312}-django4.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{310,311,312}-django5.0-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{310,311,312}-djangomain-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{38,39,310}-django4.1-{sqlite3,postgresql,mysql}-{builtin_redis,redis,memcached,pylibmc,locmem,filebased},
py{38,39,310,312}-django4.2-{sqlite3,postgresql,mysql}-{builtin_redis,redis,memcached,pylibmc,locmem,filebased},
py{310,311,312}-django5.0-{sqlite3,postgresql,mysql}-{builtin_redis,redis,memcached,pylibmc,locmem,filebased},
py{310,311,312}-djangomain-{sqlite3,postgresql,mysql}-{builtin_redis,redis,memcached,pylibmc,locmem,filebased},

[testenv]
passenv = *
Expand Down Expand Up @@ -35,14 +35,15 @@ deps =
beautifulsoup4
coverage
setenv =
sqlite3: DB_ENGINE=sqlite3
postgresql: DB_ENGINE=postgresql
mysql: DB_ENGINE=mysql
locmem: CACHE_BACKEND=locmem
filebased: CACHE_BACKEND=filebased
redis: CACHE_BACKEND=redis
memcached: CACHE_BACKEND=memcached
pylibmc: CACHE_BACKEND=pylibmc
sqlite3: DB_ENGINE=sqlite3
postgresql: DB_ENGINE=postgresql
mysql: DB_ENGINE=mysql
locmem: CACHE_BACKEND=locmem
filebased: CACHE_BACKEND=filebased
redis: CACHE_BACKEND=redis
builtin_redis: CACHE_BACKEND=builtin_redis
memcached: CACHE_BACKEND=memcached
pylibmc: CACHE_BACKEND=pylibmc
commands =
coverage run -a --source=cachalot ./runtests.py

Expand Down
Loading