From 007854a8776300401a416996a582454bf1ebfe9d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 11 Mar 2025 12:03:57 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(back)=20use=20redis=20as=20s?= =?UTF-8?q?ession=20backend=20in=20developement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to persist the session during development. Otherwise the session is reset everytime the server is restart. This behavior make developing bot a front and back feature a nigthmare, we spend our time login again and again --- src/backend/impress/settings.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index 9cffb36d..8b8a83fe 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -700,6 +700,28 @@ class Development(Base): SESSION_COOKIE_NAME = "impress_sessionid" USE_SWAGGER = True + SESSION_CACHE_ALIAS = "session" + CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.dummy.DummyCache", + }, + "session": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": values.Value( + "redis://redis:6379/2", + environ_name="REDIS_URL", + environ_prefix=None, + ), + "TIMEOUT": values.IntegerValue( + 30, # timeout in seconds + environ_name="CACHES_DEFAULT_TIMEOUT", + environ_prefix=None, + ), + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, + }, + } def __init__(self): # pylint: disable=invalid-name