Caching
The extension implement a cache strategy to store the data fetched from the different sources.
There are three cache strategies available:
- redis
- file_orc
- file_csv.
File cache
The file cache works by storing the data in an orc or csv file in the filesystem. The redis cache stores the data in a Redis database. The cache strategy can be changed at the CKAN configuration level through the admin interface or in a configuration file.
The file-type cache strategy stores the data in a file in the filesystem. The file cache is stored in the ckanext-charts directory in the CKAN storage path. The file cache is stored in an orc or csv file format.
Warning
Using file_orc cache strategy requires the pyarrow python library to be installed.
Redis cache
The redis cache strategy stores the data in a Redis database.
Each redis key has a ckanext-charts:* prefix and store the data as a CSV string.
Note
You need to have a Redis server running to use the redis cache strategy.
Cache TTL
The cache TTL can be set in the CKAN configuration file. The default value is 3600 seconds (1 hour).
The redis and file-type cache has separate TTL settings:
- The rediscache TTL can be set with theckanext.charts.redis_cache_ttlconfiguration option.
- The filecache TTL can be set with theckanext.charts.file_cache_ttlconfiguration option.
Disable cache
Cache could be disabled by setting ckanext.charts.enable_cache to false. In this case the data will be fetched from the source every time the chart is rendered. It could be useful for debugging purposes. But using it in production is not recommended, as it could lead to performance issues.