Skip to main content
Version: 2.32.2

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:

  1. Create an instance of Aperture Client.

  2. Instantiate a Flow by calling the StartFlow method with the resultCacheKey parameter set to your desired value. The first call will let Aperture initialize a cache entry for the flow, uniquely identified by the ControlPoint and ResultCacheKey values. Subsequent calls will return the cached value as part of the response object.

  3. The value stored in the cache can be retrieved by calling the ResultCache method on the Flow 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 a HIT or a MISS.
    • GetError - retrieve the error that occurred during the lookup operation.
    • GetValue - retrieve the cached value.
  4. 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.
  5. Call the EndFlow method to complete the flow.

info

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.