We are releasing a new feature – Query Caching.
What is Query Caching?
Query Caching helps to store the results of long running queries for a defined time frame.
That means, you don’t need to execute these queries and load newer data every time. You can now easily access the data that resulted from another run of that same query especially if the most current results are not necessary. Also, if another user in your project runs a query, and others also want to view the content of that, they don’t need to execute that same query again which might save a lot of time depending on the amount of data.
Unlike the common cache approach, “our cache” is preserved over time.
That means, if you change your mind in regards of the time frame or want to manually extract an old result, you can still do so.
So what exactly has changed?
Results of executed query templates are saved in the query history and can be accessed from there, too. Therefore, the Template Designer now provides a new option in the Advanced Settings. This option is enabled for all new query templates, by default, and stores the results in the cache.
For all already existing/older query templates this option was not enabled.
For running a query template with cache support, we also added a new button: Run (cached).
By using this new button, you can make use of the cached results. The service logic will automatically fetch the matching entries for you. You can also select cached entries manually using the selection box History.
The cache is then, of course, also applied to all executions via API using the new header “X-cache_time” (see our Swagger API). This allows to individually define cache times via API call.
How does this affect the dashboard and widgets?
You can also configure a caching time for each new widget individually and independently from the settings of a query template. This can be done in the data source settings of each widget.
For all new widgets, the default cache time of 30 minutes will be set automatically.
Existing widgets have this set to 0, so that the cache is disabled and existing behavior is preserved.
The UI will use this setting to load existing cache entries that match your parameters.
Also our cache logic is capable of handling relative time frames.
- User A loads a dashboard with content from the last hour. This creates a cache entry.
- Just 5 seconds later, user B opens the same dashboard to also load the last hour.
- User B will automatically get the previously cached result to directly see the content.
- The UI will trigger a background refresh, which will then update the dashboard later. So, the user can also get the most up-to-date data.
So what are the overall benefits of this?
- You can download old results whenever you want.
(The maximum for cached entries is 7 days in our object storage)
- You can easily load all cached results from the new History drop-down list in the Template Runner, Query History, or via API.
- You can cache all your queries via API calls.
- You do not have to wait anymore for content to appear every time when you open a dashboard. The previous state will directly be loaded from cache.
- You can define your own caching times for each query template and widget to achieve the optimal scenario of your use case.