Cache
Aperture's Cache can be used to reduce the load on a service by caching the results of expensive computations. It is built on top of a reliable distributed cache so that each Aperture Agent can quickly and efficiently operate on the cached data.
The Cache functionality can be used via Aperture SDKs as part of the Flow. While some SDKs might differ in their implementation and function names, the general idea is as follows:
Create an instance of Aperture
Client
.Instantiate a
Flow
by calling theStartFlow
method with theresultCacheKey
parameter set to your desired value. The first call will let Aperture initialize a cache entry for the flow, uniquely identified by theControlPoint
andResultCacheKey
values. Subsequent calls will return the cached value as part of the response object.The value stored in the cache can be retrieved by calling the
ResultCache
method on theFlow
object. It returns an object that can be used to perform the following operations:GetLookupStatus
- retrieve the status of the lookup operation, whether it was aHIT
or aMISS
.GetError
- retrieve the error that occurred during the lookup operation.GetValue
- retrieve the cached value.
While the flow is active, the following additional Cache related operations can be performed on the
Flow
object:SetResultCache
- set the cached value.DeleteResultCache
- delete the cached value.
Call the
EndFlow
method to complete the flow.
Refer to the Caching Guide for more information on how to use the
Cache via aperture-js
SDK.
Additionally, Aperture also provides a Global Cache that can be used to access
cached data across multiple flows. This is useful when the same data is required
by multiple flows. The Global Cache can be accessed via the GlobalCache
method with key
parameter on the Flow
object. It returns the same object as
the ResultCache
method.
Similar to ResultCache
, Set
and Delete
methods can be used to set and
delete entries in the Global Cache.