From 6f923aea69826bb005baac9426cbef5c8d4218a6 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Fri, 25 Mar 2022 15:10:07 +0200 Subject: [PATCH 1/2] fix(caching): support metastore cache for non-required caches --- superset/utils/cache_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/superset/utils/cache_manager.py b/superset/utils/cache_manager.py index f7bb8d9e8f89f..062649a5f919f 100644 --- a/superset/utils/cache_manager.py +++ b/superset/utils/cache_manager.py @@ -40,7 +40,7 @@ def _init_cache( ) -> None: cache_config = app.config[cache_config_key] cache_type = cache_config.get("CACHE_TYPE") - if required and cache_type in (None, "SupersetMetastoreCache"): + if required and cache_type is None or cache_type == "SupersetMetastoreCache": if cache_type is None and not app.debug: logger.warning( "Falling back to the built-in cache, that stores data in the " @@ -49,12 +49,13 @@ def _init_cache( "another dedicated caching backend for production deployments", cache_config_key, ) + cache_type = CACHE_IMPORT_PATH cache_key_prefix = cache_config.get("CACHE_KEY_PREFIX", cache_config_key) cache_config.update( - {"CACHE_TYPE": CACHE_IMPORT_PATH, "CACHE_KEY_PREFIX": cache_key_prefix} + {"CACHE_TYPE": cache_type, "CACHE_KEY_PREFIX": cache_key_prefix} ) - if "CACHE_DEFAULT_TIMEOUT" not in cache_config: + if cache_type is not None and "CACHE_DEFAULT_TIMEOUT" not in cache_config: default_timeout = app.config.get("CACHE_DEFAULT_TIMEOUT") cache_config["CACHE_DEFAULT_TIMEOUT"] = default_timeout From 90e2d715bb75334bf2a23eaaf0c54f79d04f1d66 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Fri, 25 Mar 2022 15:26:02 +0200 Subject: [PATCH 2/2] lint --- superset/utils/cache_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/utils/cache_manager.py b/superset/utils/cache_manager.py index 062649a5f919f..c67644f308b1f 100644 --- a/superset/utils/cache_manager.py +++ b/superset/utils/cache_manager.py @@ -40,7 +40,7 @@ def _init_cache( ) -> None: cache_config = app.config[cache_config_key] cache_type = cache_config.get("CACHE_TYPE") - if required and cache_type is None or cache_type == "SupersetMetastoreCache": + if (required and cache_type is None) or cache_type == "SupersetMetastoreCache": if cache_type is None and not app.debug: logger.warning( "Falling back to the built-in cache, that stores data in the "