From c5869024e002b4d5b57b7c7bc96b054e7782bf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Tue, 30 Jan 2024 03:28:52 +0100 Subject: [PATCH] Don't cache if DEBUG --- feedvault/settings.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/feedvault/settings.py b/feedvault/settings.py index 9f46650..3a7ccca 100644 --- a/feedvault/settings.py +++ b/feedvault/settings.py @@ -173,13 +173,19 @@ SITE_ID = 1 REDIS_PASSWORD: str = os.getenv(key="REDIS_PASSWORD", default="") REDIS_HOST: str = os.getenv(key="REDIS_HOST", default="192.168.1.2") REDIS_PORT: str = os.getenv(key="REDIS_PORT", default="6379") -CACHES: dict[str, dict[str, str]] = { - "default": { - "BACKEND": "django.core.cache.backends.redis.RedisCache", - "LOCATION": f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/0", - }, -} - -CACHE_MIDDLEWARE_ALIAS = "default" -CACHE_MIDDLEWARE_SECONDS = 600 # 10 minutes -CACHE_MIDDLEWARE_KEY_PREFIX = "feedvault" +if not DEBUG: + CACHES: dict[str, dict[str, str]] = { + "default": { + "BACKEND": "django.core.cache.backends.redis.RedisCache", + "LOCATION": f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/0", + }, + } + CACHE_MIDDLEWARE_ALIAS = "default" + CACHE_MIDDLEWARE_SECONDS = 600 # 10 minutes + CACHE_MIDDLEWARE_KEY_PREFIX = "feedvault" +else: + CACHES: dict[str, dict[str, str]] = { + "default": { + "BACKEND": "django.core.cache.backends.dummy.DummyCache", + }, + }