villebro commented on a change in pull request #18976:
URL: https://github.com/apache/superset/pull/18976#discussion_r817145733



##########
File path: superset/config.py
##########
@@ -576,31 +578,44 @@ def _try_json_readsha(filepath: str, length: int) -> 
Optional[str]:
 # Setup image size default is (300, 200, True)
 # IMG_SIZE = (300, 200, True)
 
-# Default cache timeout, applies to all cache backends unless specifically 
overridden in
+
+# Default cache config, applies to all cache backends unless specifically 
overridden in
 # each cache config.
-CACHE_DEFAULT_TIMEOUT = int(timedelta(days=1).total_seconds())
+def DEFAULT_CACHE_CONFIG_FUNC(  # pylint: disable=invalid-name
+    app: Flask,
+) -> CacheConfig:
+    default_timeout = app.config.get("CACHE_DEFAULT_TIMEOUT")
+    if default_timeout is None:
+        default_timeout = int(timedelta(days=1).total_seconds())
+    else:
+        logger.warning(
+            "The global config flag CACHE_DEFAULT_TIMEOUT has been deprecated "
+            "and will be removed in Superset 2.0. Please set default cache 
options in "
+            "DEFAULT_CACHE_CONFIG_FUNC"
+        )
+
+    return {
+        "CACHE_TYPE": "SimpleCache" if app.debug else "NullCache",
+        "CACHE_THRESHOLD": math.inf,

Review comment:
       It turns out `FileSystemCache` treats `"CACHE_THRESHOLD": 0` as "no 
threshold", while `SimpleCache` treats it as "expire everything".
   - `SimpleCache`: 
https://github.com/pallets-eco/flask-caching/blob/058629ca4d38d1215fd911d41443751d0806bd4c/src/flask_caching/backends/simplecache.py#L61-L69
   - `FileSystemCache`: 
https://github.com/pallets-eco/flask-caching/blob/058629ca4d38d1215fd911d41443751d0806bd4c/src/flask_caching/backends/filesystemcache.py#L128-L147
   
   Both default to 500 if unset (The setting has no effect on other backends). 
To avoid a situation where someone wonders why their cache starts expiring 
entries before the timeout I decided to set `CACHE_THRESHOLD` to `math.inf`.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to