mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
chore(cache): default to SimpleCache in debug mode (#18976)
* chore(cache): default to SimpleCache in debug mode * lint * clean up type * use util * fix integration test cache configs * remove util from cache manager * remove trailing comma * fix more tests * fix truthiness check * fix tests and improve deprecation notice * fix default cache threshold * move debug check to cache_manager * remove separate getter * update docs * remove default cache config
This commit is contained in:
@@ -7,20 +7,25 @@ version: 1
|
||||
|
||||
## Caching
|
||||
|
||||
Superset uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purpose. For security reasons,
|
||||
there are two separate cache configs for Superset's own metadata (`CACHE_CONFIG`) and charting data queried from
|
||||
connected datasources (`DATA_CACHE_CONFIG`). However, Query results from SQL Lab are stored in another backend
|
||||
called `RESULTS_BACKEND`, See [Async Queries via Celery](/docs/installation/async-queries-celery) for details.
|
||||
|
||||
Configuring caching is as easy as providing `CACHE_CONFIG` and `DATA_CACHE_CONFIG` in your
|
||||
Superset uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purpose. Configuring caching is as easy as providing a custom cache config in your
|
||||
`superset_config.py` that complies with [the Flask-Caching specifications](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching).
|
||||
|
||||
Flask-Caching supports various caching backends, including Redis, Memcached, SimpleCache (in-memory), or the
|
||||
local filesystem.
|
||||
local filesystem. Custom cache backends are also supported. See [here](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends) for specifics.
|
||||
The following cache configurations can be customized:
|
||||
- Metadata cache (optional): `CACHE_CONFIG`
|
||||
- Charting data queried from datasets (optional): `DATA_CACHE_CONFIG`
|
||||
- SQL Lab query results (optional): `RESULTS_BACKEND`. See [Async Queries via Celery](/docs/installation/async-queries-celery) for details
|
||||
- Dashboard filter state (required): `FILTER_STATE_CACHE_CONFIG`.
|
||||
- Explore chart form data (required): `EXPLORE_FORM_DATA_CACHE_CONFIG`
|
||||
|
||||
Please note, that Dashboard and Explore caching is required. When running Superset in debug mode, both Explore and Dashboard caches will default to `SimpleCache`;
|
||||
However, trying to run Superset in non-debug mode without defining a cache for these will cause the application to fail on startup. When running
|
||||
superset in single-worker mode, any cache backend is supported. However, when running Superset in on a multi-worker setup, a dedicated cache is required. For this
|
||||
we recommend using either Redis or Memcached:
|
||||
|
||||
- Redis (recommended): we recommend the [redis](https://pypi.python.org/pypi/redis) Python package
|
||||
- Memcached: we recommend using [pylibmc](https://pypi.org/project/pylibmc/) client library as
|
||||
`python-memcached` does not handle storing binary data correctly.
|
||||
- Redis: we recommend the [redis](https://pypi.python.org/pypi/redis) Python package
|
||||
|
||||
Both of these libraries can be installed using pip.
|
||||
|
||||
@@ -28,16 +33,7 @@ For chart data, Superset goes up a “timeout search path”, from a slice's con
|
||||
to the datasource’s, the database’s, then ultimately falls back to the global default
|
||||
defined in `DATA_CACHE_CONFIG`.
|
||||
|
||||
```
|
||||
DATA_CACHE_CONFIG = {
|
||||
'CACHE_TYPE': 'redis',
|
||||
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24, # 1 day default (in secs)
|
||||
'CACHE_KEY_PREFIX': 'superset_results',
|
||||
'CACHE_REDIS_URL': 'redis://localhost:6379/0',
|
||||
}
|
||||
```
|
||||
|
||||
Custom cache backends are also supported. See [here](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends) for specifics.
|
||||
## Celery beat
|
||||
|
||||
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