From 702c306ad75e0502f9daaf257136cd309bb4d0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Thu, 3 Mar 2016 11:26:28 +0100 Subject: [PATCH] Add django-redis --- .travis.yml | 1 + requirements.txt | 1 + settings/common.py | 2 ++ settings/local.py.example | 11 +++++++++++ settings/testing.py | 10 ++++++++++ settings/travis.py | 10 ++++++++++ 6 files changed, 35 insertions(+) diff --git a/.travis.yml b/.travis.yml index e07f042c..f539f181 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ python: - "3.5" services: - rabbitmq # will start rabbitmq-server + - redis-server cache: - apt - pip diff --git a/requirements.txt b/requirements.txt index 181e863f..39a7c8ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,7 @@ amqp==1.4.9 djmail==0.12.0.post1 django-pgjson==0.3.1 djorm-pgarray==1.2 +django-redis==4.3.0 django-jinja==2.1.2 jinja2==2.8 pygments==2.0.2 diff --git a/settings/common.py b/settings/common.py index c871c54c..fd3631a4 100644 --- a/settings/common.py +++ b/settings/common.py @@ -35,6 +35,7 @@ DATABASES = { } } +# Default cache (you can use redis cache, see settings/locale.py.example) CACHES = { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", @@ -42,6 +43,7 @@ CACHES = { } } + PASSWORD_HASHERS = [ "django.contrib.auth.hashers.PBKDF2PasswordHasher", ] diff --git a/settings/local.py.example b/settings/local.py.example index d0052032..e22a7ec0 100644 --- a/settings/local.py.example +++ b/settings/local.py.example @@ -33,6 +33,17 @@ DATABASES = { } } +# You can use redis cache +#CACHES = { +# "default": { +# "BACKEND": "django_redis.cache.RedisCache", +# "LOCATION": "'redis://localhost:6379/1", +# "OPTIONS": { +# "CLIENT_CLASS": "django_redis.client.DefaultClient", +# } +# } +#} + #SITES = { # "api": { # "scheme": "http", diff --git a/settings/testing.py b/settings/testing.py index b1549a8a..abb66205 100644 --- a/settings/testing.py +++ b/settings/testing.py @@ -17,6 +17,16 @@ from .development import * +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "'redis://localhost:6379/1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + } + } +} + SKIP_SOUTH_TESTS = True SOUTH_TESTS_MIGRATE = False CELERY_ALWAYS_EAGER = True diff --git a/settings/travis.py b/settings/travis.py index 8481688c..f0a56652 100644 --- a/settings/travis.py +++ b/settings/travis.py @@ -24,3 +24,13 @@ DATABASES = { 'USERNAME': 'postgres', } } + +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "'redis://localhost:6379/1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + } + } +}