From c438725c7a1aae4e9fb6edfca7c1ede2093b0972 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 9 Jun 2026 09:50:51 -0300 Subject: [PATCH] [chores] Separated session redis bucket from cache bucket --- images/common/openwisp/settings.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/images/common/openwisp/settings.py b/images/common/openwisp/settings.py index 048de604..b6afb0d0 100644 --- a/images/common/openwisp/settings.py +++ b/images/common/openwisp/settings.py @@ -143,7 +143,7 @@ FORM_RENDERER = "django.forms.renderers.TemplatesSetting" SESSION_ENGINE = "django.contrib.sessions.backends.cache" -SESSION_CACHE_ALIAS = "default" +SESSION_CACHE_ALIAS = "sessions" SESSION_COOKIE_DOMAIN = ROOT_DOMAIN # Required for API request from Django admin @@ -173,7 +173,8 @@ REDIS_BASE_URL = f"{REDIS_SCHEME}://{credentials}{REDIS_HOST}:{REDIS_PORT}" REDIS_CACHE_URL = os.environ.get("REDIS_CACHE_URL", f"{REDIS_BASE_URL}/0") -CHANNEL_REDIS_HOST = os.environ.get("CHANNEL_REDIS_URL", f"{REDIS_BASE_URL}/1") +REDIS_SESSIONS_URL = os.environ.get("REDIS_SESSIONS_URL", f"{REDIS_BASE_URL}/1") +CHANNEL_REDIS_HOST = os.environ.get("CHANNEL_REDIS_URL", f"{REDIS_BASE_URL}/3") CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL", f"{REDIS_BASE_URL}/2") CELERY_TASK_ACKS_LATE = True @@ -240,11 +241,19 @@ "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", }, - } + }, + "sessions": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": REDIS_SESSIONS_URL, + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, + }, } if REDIS_PASS: CACHES["default"]["OPTIONS"]["PASSWORD"] = os.environ["REDIS_PASS"] + CACHES["sessions"]["OPTIONS"]["PASSWORD"] = os.environ["REDIS_PASS"] # Leaflet Configurations # https://django-leaflet.readthedocs.io/en/latest/templates.html#configuration