diff --git a/docs/docs/start/config.md b/docs/docs/start/config.md index de4ec4a3e1..a42cfebb7b 100644 --- a/docs/docs/start/config.md +++ b/docs/docs/start/config.md @@ -327,7 +327,7 @@ Enabling global caching requires connection to a redis server (which is separate The following cache settings are available: {{ configtable() }} -{{ configsetting("INVENTREE_CACHE_ENABLED") }} Enable redis caching | +{{ configsetting("INVENTREE_CACHE_ENABLED", default="True if `INVENTREE_CACHE_HOST` is set") }} Enable redis caching | {{ configsetting("INVENTREE_CACHE_HOST") }} Cache server host | {{ configsetting("INVENTREE_CACHE_PORT") }} Cache server port | {{ configsetting("INVENTREE_CACHE_PASSWORD") }} Cache server password | @@ -341,6 +341,8 @@ The following cache settings are available: {{ configsetting("INVENTREE_CACHE_KEEPALIVE_INTERVAL") }} Cache keepalive interval | {{ configsetting("INVENTREE_CACHE_USER_TIMEOUT") }} Cache user timeout | +!!! tip "Cache Host" + If a value is provided for `INVENTREE_CACHE_HOST`, global caching will be enabled, unless the `INVENTREE_CACHE_ENABLED` setting is explicitly set to `False`. !!! tip "Cache Password" The value specified for `INVENTREE_CACHE_PASSWORD` should not contain comma `,` or colon `:` characters, otherwise the connection to the cache server may fail. diff --git a/src/backend/InvenTree/InvenTree/cache.py b/src/backend/InvenTree/InvenTree/cache.py index 07547eb667..f913330aad 100644 --- a/src/backend/InvenTree/InvenTree/cache.py +++ b/src/backend/InvenTree/InvenTree/cache.py @@ -69,7 +69,7 @@ def is_global_cache_enabled() -> bool: return False # Test if the cache is configured - if not cache_host(): + if not host: logger.warning('Global cache is enabled, but no cache host is configured!') return False diff --git a/src/backend/InvenTree/config_template.yaml b/src/backend/InvenTree/config_template.yaml index 16981c89f3..e4b9c985ab 100644 --- a/src/backend/InvenTree/config_template.yaml +++ b/src/backend/InvenTree/config_template.yaml @@ -186,10 +186,10 @@ background: max_attempts: 5 # External cache configuration (refer to the documentation for full list of options) -cache: - enabled: false - host: 'inventree-cache' - port: 6379 +#cache: +# enabled: false +# host: 'inventree-cache' +# port: 6379 # Login configuration login_confirm_days: 3