2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-04-15 07:48:51 +00:00

Add redis database index support (#11732)

This commit is contained in:
Dään
2026-04-12 23:19:34 +00:00
committed by GitHub
parent 8e73a229a9
commit fc06aa354a
2 changed files with 10 additions and 2 deletions

View File

@@ -50,6 +50,11 @@ def cache_user():
return cache_setting('user', None)
def cache_db():
"""Return the cache database index."""
return cache_setting('db', 0, typecast=int)
def is_global_cache_enabled() -> bool:
"""Check if the global cache is enabled.
@@ -95,9 +100,11 @@ def get_cache_config(global_cache: bool) -> dict:
user = cache_user() or ''
if password:
redis_url = f'redis://{user}:{password}@{cache_host()}:{cache_port()}/0'
redis_url = (
f'redis://{user}:{password}@{cache_host()}:{cache_port()}/{cache_db()}'
)
else:
redis_url = f'redis://{cache_host()}:{cache_port()}/0'
redis_url = f'redis://{cache_host()}:{cache_port()}/{cache_db()}'
keepalive_options = {
'TCP_KEEPCNT': cache_setting('keepalive_count', 5, typecast=int),