# Caching

Spotrix uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purposes. Flask-Caching supports various caching backends, including Redis (recommended), Memcached, SimpleCache (in-memory), or the local filesystem. [Custom cache backends](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends) are also supported.

Caching can be configured by providing a dictionaries in `spotrix_config.py` that comply with [the Flask-Caching config specifications](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching).

The following cache configurations can be customized in this way:

* Dashboard filter state: FILTER\_STATE\_CAHCE\_CONFIG **`required`**
* Explore chart from data: EXPLORE\_FROM\_DATA\_CACHE\_CONFIG **`required`**
* Metadata cache: CACHE\_CONFIG **`optional`**
* Charting data required from datasets: DATA\_CACHE\_CONFIG **`optional`**

For example, to configure the filter state cache using redis:

```python
FILTER_STATE_CACHE_CONFIG = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': 86400,
    'CACHE_KEY_PREFIX': 'spotrix_filter_cache',
    'CACHE_REDIS_URL': 'redis://localhost:6379/0'
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ciusji.gitbook.io/spotrix/configuration/caching.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
