mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-14 15:28:52 +00:00
Add redis database index support (#11732)
This commit is contained in:
@@ -321,6 +321,7 @@ The following cache settings are available:
|
|||||||
| INVENTREE_CACHE_PORT | cache.port | Cache server port | 6379 |
|
| INVENTREE_CACHE_PORT | cache.port | Cache server port | 6379 |
|
||||||
| INVENTREE_CACHE_PASSWORD | cache.password | Cache server password | none |
|
| INVENTREE_CACHE_PASSWORD | cache.password | Cache server password | none |
|
||||||
| INVENTREE_CACHE_USER | cache.user | Cache server username | none |
|
| INVENTREE_CACHE_USER | cache.user | Cache server username | none |
|
||||||
|
| INVENTREE_CACHE_DB | cache.db | Cache server database index | 0 |
|
||||||
| INVENTREE_CACHE_CONNECT_TIMEOUT | cache.connect_timeout | Cache connection timeout (seconds) | 3 |
|
| INVENTREE_CACHE_CONNECT_TIMEOUT | cache.connect_timeout | Cache connection timeout (seconds) | 3 |
|
||||||
| INVENTREE_CACHE_TIMEOUT | cache.timeout | Cache timeout (seconds) | 3 |
|
| INVENTREE_CACHE_TIMEOUT | cache.timeout | Cache timeout (seconds) | 3 |
|
||||||
| INVENTREE_CACHE_TCP_KEEPALIVE | cache.tcp_keepalive | Cache TCP keepalive | True |
|
| INVENTREE_CACHE_TCP_KEEPALIVE | cache.tcp_keepalive | Cache TCP keepalive | True |
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ def cache_user():
|
|||||||
return cache_setting('user', None)
|
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:
|
def is_global_cache_enabled() -> bool:
|
||||||
"""Check if the global cache is enabled.
|
"""Check if the global cache is enabled.
|
||||||
|
|
||||||
@@ -95,9 +100,11 @@ def get_cache_config(global_cache: bool) -> dict:
|
|||||||
user = cache_user() or ''
|
user = cache_user() or ''
|
||||||
|
|
||||||
if password:
|
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:
|
else:
|
||||||
redis_url = f'redis://{cache_host()}:{cache_port()}/0'
|
redis_url = f'redis://{cache_host()}:{cache_port()}/{cache_db()}'
|
||||||
|
|
||||||
keepalive_options = {
|
keepalive_options = {
|
||||||
'TCP_KEEPCNT': cache_setting('keepalive_count', 5, typecast=int),
|
'TCP_KEEPCNT': cache_setting('keepalive_count', 5, typecast=int),
|
||||||
|
|||||||
Reference in New Issue
Block a user