craig-rueda commented on a change in pull request #9020: [Caching] Ensure cache
is always created
URL:
https://github.com/apache/incubator-superset/pull/9020#discussion_r370911191
##########
File path: superset/utils/cache_manager.py
##########
@@ -27,30 +27,26 @@ def __init__(self) -> None:
self._tables_cache = None
self._cache = None
- def init_app(self, app):
- self._cache = self._setup_cache(app, app.config.get("CACHE_CONFIG"))
+ def init_app(self, app: Flask) -> None:
+ self._cache = self._setup_cache(app, app.config["CACHE_CONFIG"])
self._tables_cache = self._setup_cache(
- app, app.config.get("TABLE_NAMES_CACHE_CONFIG")
+ app, app.config["TABLE_NAMES_CACHE_CONFIG"]
)
@staticmethod
- def _setup_cache(app: Flask, cache_config) -> Optional[Cache]:
+ def _setup_cache(app: Flask, cache_config: CacheConfig) -> Cache:
"""Setup the flask-cache on a flask app"""
- if cache_config:
- if isinstance(cache_config, dict):
- if cache_config.get("CACHE_TYPE") != "null":
- return Cache(app, config=cache_config)
- else:
- # Accepts a custom cache initialization function,
- # returning an object compatible with Flask-Caching API
- return cache_config(app)
+ if isinstance(cache_config, dict):
Review comment:
Nice, this was confusing logic
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]