mirror of
https://github.com/apache/superset.git
synced 2026-04-18 07:35:09 +00:00
chore: Using cache factory method (#10887)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -34,23 +34,7 @@ CACHE_CONFIG = {
|
||||
}
|
||||
```
|
||||
|
||||
It is also possible to pass a custom cache initialization function in the config to handle
|
||||
additional caching use cases. The function must return an object that is compatible with the
|
||||
[Flask-Cache API](https://pythonhosted.org/Flask-Cache/).
|
||||
|
||||
```python
|
||||
from custom_caching import CustomCache
|
||||
|
||||
def init_cache(app):
|
||||
"""Takes an app instance and returns a custom cache backend"""
|
||||
config = {
|
||||
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24, # 1 day default (in secs)
|
||||
'CACHE_KEY_PREFIX': 'superset_results',
|
||||
}
|
||||
return CustomCache(app, config)
|
||||
|
||||
CACHE_CONFIG = init_cache
|
||||
```
|
||||
Custom cache backends are also supported. See [here](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends) for specifics.
|
||||
|
||||
Superset has a Celery task that will periodically warm up the cache based on different strategies.
|
||||
To use it, add the following to the `CELERYBEAT_SCHEDULE` section in `config.py`:
|
||||
|
||||
Reference in New Issue
Block a user