From 6172c0beacdb927b2409dc54a5c7e2b2ad56bd6b Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Sun, 9 Jul 2017 13:27:15 +0200 Subject: [PATCH] upgrade to latest dynamic_preferences and use redis as cache even locally --- api/config/settings/common.py | 12 ++++++++++++ api/config/settings/local.py | 8 -------- api/config/settings/production.py | 12 +----------- api/requirements/base.txt | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/api/config/settings/common.py b/api/config/settings/common.py index 70804c3c..d71992be 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -260,6 +260,18 @@ BROKER_URL = env("CELERY_BROKER_URL", default='django://') ########## END CELERY +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "{0}/{1}".format(env.cache_url('REDIS_URL', default="redis://127.0.0.1:6379"), 0), + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + "IGNORE_EXCEPTIONS": True, # mimics memcache behavior. + # http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior + } + } +} + # Location of root django.contrib.admin URL, use {% url 'admin:index' %} ADMIN_URL = r'^admin/' # Your common stuff: Below this line define 3rd party library settings diff --git a/api/config/settings/local.py b/api/config/settings/local.py index 762ffe7a..e8108e98 100644 --- a/api/config/settings/local.py +++ b/api/config/settings/local.py @@ -28,14 +28,6 @@ EMAIL_PORT = 1025 EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend') -# CACHING -# ------------------------------------------------------------------------------ -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - 'LOCATION': '' - } -} # django-debug-toolbar # ------------------------------------------------------------------------------ diff --git a/api/config/settings/production.py b/api/config/settings/production.py index 937328d1..e8a05bd3 100644 --- a/api/config/settings/production.py +++ b/api/config/settings/production.py @@ -100,17 +100,7 @@ DATABASES['default'] = env.db("DATABASE_URL") # CACHING # ------------------------------------------------------------------------------ # Heroku URL does not pass the DB number, so we parse it in -CACHES = { - "default": { - "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "{0}/{1}".format(env.cache_url('REDIS_URL', default="redis://127.0.0.1:6379"), 0), - "OPTIONS": { - "CLIENT_CLASS": "django_redis.client.DefaultClient", - "IGNORE_EXCEPTIONS": True, # mimics memcache behavior. - # http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior - } - } -} + # LOGGING CONFIGURATION diff --git a/api/requirements/base.txt b/api/requirements/base.txt index bdf17cf9..e7bc870c 100644 --- a/api/requirements/base.txt +++ b/api/requirements/base.txt @@ -55,4 +55,4 @@ mutagen==1.38 # Until this is merged git+https://github.com/EliotBerriot/PyMemoize.git@django -django-dynamic-preferences>=1.2,<1.3 +django-dynamic-preferences>=1.3,<1.4 -- GitLab