Syvizo


Cache Response



When to use

Use this policy when you want to use cacheddata to be sent in response instead of the request going to backend API. This should be used for the data that does not change frequently.


Details

Some API responses send data that does notchange frequently and the same data is sent for multiple requests. When the cache isnot used, the requests go to the backend API and the processing is done to get theresponse. This takes longer to send response and increase processing load on thebackend API unnecessarily. 

This type of data can be stored in cache andsent in the response without sending the request to the backend API. Doing soimproves the response times and saves on the resources for backend API.

Cache Response policy can be used to dothis.

When this policy is configured in the flow,the cache is looked up based on the cache key input field for any request that isreceived. If the data is not found in cache, which will be the case for the firstrequest, then the backend API is called and the response data is stored in cache.For any further requests with same key the data will be taken from the cache andsent in response till the time cache entry is valid (not expired).


Configuration

The configuration fields for the policyare:

[* Indicates a mandatory field]

Name *: Display name of the policy

Description: Description of policy

Enabled: Flag to indicate if the policy is enabled. Ifthis field is not checked, the policy will be ignored at runtime and any fields fromits output will contain a default initial value

Continue on Error: Flag to indicate that the flow should continueeven if this policy throws an error

Cache Key: Key to identify data in cache. Value from thisconfiguration field is used only if the input field “cacheKey” of the policy is notset

Expiry Date: Specifies the date when the policy shouldstart The date format is dd/mm/yyyy

Expiry Time: Specifies the time when the policy shouldstart. Time format is HH:mm:ss

TTL in seconds: Cache Time to live specifies how long aftercache is valid after added. If present, this overrides Expiry date and expiry time.The cache will be removed after this time is elapsed and for any next request, thecache data will be re-populated with the response from the backend API call

Lookup Timeout in seconds: Maximum time the cache lookup will last. If thecache is not found within this time, the backend API call will be make and data willbe retrieved from the backend API call.

Skip Cache Lookup: If this is checked, then the cache lookup willnot be performed and the request will be sent to backend API. The data in responsefrom the backend will be set in the cache and will overwrite the data if it isalready present in cache.

Skip Cache Population: If this is checked, then the cache lookup is doneand data is returned from cache if it is found. However, if the data is not found incache and request is sent to backend API, then the data from the backend APIresponse will not be added to cache.


Input fields

cacheKey: Key based on which cache lookup isdone. This value overrides the value in configuration field “Cache Key”


Output fields

status: returns boolean true if the data is found incache, otherwise returns false

Cache value: value found in cache