The purpose of this guide is to help you understand what caching is and when you may want to cache your query to speed up your analysis response. The follow-up piece to this guide on Cached Queries is the guide on the topic: Cached Datasets.
What is Caching?
Use Caching when you are ready to build on top of Keen Compute query results.
Cached Queries and Cached Datasets regularly perform the computation in advance so that results can always be retrieved with sub-second latency. A common use case for caching is to prepare query results that are going to be embedded into live customer-facing dashboards. This provides your customers with a lightning fast and positive user experience every time. Advanced use cases leverage pre-computed and cached results to intelligently personalize the application based on the user’s historical behavior.
Saved queries are a super user-friendly way to revisit your favorite metrics. Rather than entering the same query parameters over and over again, queries can be easily saved, edited, and shared with your teammates. This way everyone can keep up to date with the most important metrics.
Saved Queries are a simple way to put your metrics and charts into our hosted Dashboards application. Saved queries are fully supported by the Keen API, meaning you can access your saved queries programmatically from anything you build on top of Keen’s platform. We’ve streamlined our UI to make it easier for you to customize and revisit your queries again and again.
Create Cached queries via the Keen API or the Explorer UI. See our detailed API reference documentation on Query Caching for details & code samples.
When you create a Cached Query, you can control the “refresh_rate”. This defines the specific interval at which you would like the query to be automatically computed on our side.
Turning a Saved Query into a Cached Query
You can create a Cached Query right from the Explorer. If you haven’t already saved your query, give it a name (ex: “Purchases this Month”) to save the query. Then, to cache your most important queries just click the “Enable Caching” checkbox and set your refresh rate.
Cached queries are automatically configured with a refresh_rate of every 4 hours. This query computation interval can be edited to match your application’s needs – from being prepared every 24 hours (daily) to as frequently as every hour. Cached Queries that refresh more frequently will generate more properties scanned.
To find out whether your query has successfully been cached, the Explorer will show you “Caching is enabled” and lets you know when the query was last computed. Sample:
Retrieve a List of All Saved & Cached Queries
To get a full list of the queries you’ve saved and cached, see the API call for: Getting All Saved Query Definitions.
Ready to learn about Cached Datasets?
See our follow-up guide on caching: Cached Datasets.