Skip to content

Commit 2981b81

Browse files
committed
Support specifying the Redis Database to use on the host
Database zero is the default that the Python redis client uses, so default to that to avoid breakage. Since DLQ uses KEYS it's potentially useful to be able to run it in its own database as that may limit the performance concerns around the KEYS command.
1 parent 9cb0607 commit 2981b81

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

django_lightweight_queue/app_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def setting(suffix: str, default: T) -> T:
4343
REDIS_HOST = setting('REDIS_HOST', '127.0.0.1') # type: str
4444
REDIS_PORT = setting('REDIS_PORT', 6379) # type: int
4545
REDIS_PASSWORD = setting('REDIS_PASSWORD', None) # type: Optional[str]
46+
REDIS_DATABASE = setting('REDIS_DATABASE', 0) # type: int
4647
REDIS_PREFIX = setting('REDIS_PREFIX', '') # type: str
4748

4849
ENABLE_PROMETHEUS = setting('ENABLE_PROMETHEUS', False) # type: bool

django_lightweight_queue/backends/redis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self) -> None:
2020
host=app_settings.REDIS_HOST,
2121
port=app_settings.REDIS_PORT,
2222
password=app_settings.REDIS_PASSWORD,
23+
db=app_settings.REDIS_DATABASE,
2324
)
2425

2526
def enqueue(self, job: Job, queue: QueueName) -> None:

django_lightweight_queue/backends/reliable_redis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self) -> None:
4646
host=app_settings.REDIS_HOST,
4747
port=app_settings.REDIS_PORT,
4848
password=app_settings.REDIS_PASSWORD,
49+
db=app_settings.REDIS_DATABASE,
4950
)
5051

5152
def startup(self, queue: QueueName) -> None:

0 commit comments

Comments
 (0)