2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-05-09 11:08:54 +00:00

Add redis database index support (#11732) (#11736)

(cherry picked from commit fc06aa354a)

Co-authored-by: Dään <12813916+hartigdan@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2026-04-13 09:24:24 +10:00
committed by GitHub
parent 72cb873d8d
commit c94874e3be
2 changed files with 10 additions and 2 deletions
+9 -2
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),