The cache API provides a create, read, update and delete interface to a key value cache. This interface satisfies 80% of the use cases in application development for a cache. It allows you to implement cache invalidation strategies in your application and keep stress off of your data stores when users are requesting very hot paths. The design goal of this API was simplicity and ease of use. You provide a key and a json document to your store and it is cached. You get the document from your cache by making simple GET call with the key identifier.
When your application is performing a high volume of reads on the datastore, one way to keep your datastore from being overloaded with requests is to cache heavily requested documents. You can then use the cache to read the documents. With this pattern, the cache will be continually updated with the most recent documents, you would then write to the to the cache once a document was successfully created on the datastore, and then client requests would check the cache before checking the datastore for documents.
Caches are great for counts and sums because they reduce the need to perform complex queries to get a totals or sums. You can proactively update the count or sum in the cache as you go and then when a request comes in to retrieve the value from the cache, if the value is not there then run the expensive query to get the value and post it to the cache for next time.
Searching can also be an expensive process and if the same search is run over and over why re-do the extra work if nothing has changed. By using the cache service you can push all the result of a given search into the cache and when that search is run again simply return the results from the cache. This use case is similar to the data cache but instead of caching a single document per key, you are caching a set of documents per key from the search request. You may want to only have these items live in the cache for a short period of time. You can use the ttl property tp specify how long you want to cache a given key/value pair.
Need specific help? You can always reach out to our support team for any additional assistance at checkout our help desk