From 1772bc7257e55daab43dd9e01e8fe2b36b17e506 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Thu, 15 May 2025 13:16:18 -0500 Subject: [PATCH] Configure Redis to not write to disk and also run in unprotect mode if running in debug mode. --- core/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/utils.py b/core/utils.py index 3a5d84f4..6b5e6815 100644 --- a/core/utils.py +++ b/core/utils.py @@ -52,6 +52,24 @@ class RedisClient: # Validate connection with ping client.ping() client.flushdb() + + # Disable persistence on first connection - improves performance + # Only try to disable if not in a read-only environment + try: + client.config_set('save', '') # Disable RDB snapshots + client.config_set('appendonly', 'no') # Disable AOF logging + + # Disable protected mode when in debug mode + if os.environ.get('DISPATCHARR_DEBUG', '').lower() == 'true': + client.config_set('protected-mode', 'no') # Disable protected mode in debug + logger.warning("Redis protected mode disabled for debug environment") + + logger.trace("Redis persistence disabled for better performance") + except redis.exceptions.ResponseError: + # This might fail if Redis is configured to prohibit CONFIG command + # or if running in protected mode - that's okay + logger.error("Could not modify Redis persistence settings (may be restricted)") + logger.info(f"Connected to Redis at {redis_host}:{redis_port}/{redis_db}") cls._client = client