Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Enhancement: Allow to set a prefix for keys and channels in redis (#3993)

amo13a0005c8b3e52
diff --git a/docs/configuration.md b/docs/configuration.md
index 0ed2218a6..c38221e50 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -35,6 +35,12 @@ matcher.
Defaults to `redis://localhost:6379`.
+`PAPERLESS_REDIS_PREFIX=<prefix>`
+
+: Prefix to be used in Redis for keys and channels. Useful for sharing one Redis server among multiple Paperless instances.
+
+ Defaults to no prefix.
+
### Database
`PAPERLESS_DBENGINE=<engine_name>`
diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index b33d7fb7d..7d2dda0d9 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -364,6 +364,7 @@ CHANNEL_LAYERS = {
"hosts": [_CHANNELS_REDIS_URL],
"capacity": 2000, # default 100
"expiry": 15, # default 60
+ "prefix": os.getenv("PAPERLESS_REDIS_PREFIX", ""),
},
},
}
@@ -679,6 +680,9 @@ CELERY_TASK_SEND_SENT_EVENT = True
CELERY_SEND_TASK_SENT_EVENT = True
CELERY_BROKER_CONNECTION_RETRY = True
CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True
+CELERY_BROKER_TRANSPORT_OPTIONS = {
+ "global_keyprefix": os.getenv("PAPERLESS_REDIS_PREFIX", ""),
+}
CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_TIME_LIMIT: Final[int] = __get_int("PAPERLESS_WORKER_TIMEOUT", 1800)