Insert Data in CacheAdmin Scope

Note: Ensure you have installed the required package to use this SDK method.

Using the put() SDK method, you can insert a cache item. You can insert a key-value pair in an existing cache segment in your Catalyst project. The key name and key value are of the String type and are passed as arguments to the method. The promise returned here will be resolved to a JSON object.

You can also pass the expiry time for the cache item optionally. If you do not pass that value, the expiration time will be set to 48 hours by default.

The segment reference used in the code snippet below is the segment instance.

copy
//Insert Cache by passing the key-value pair 
const cache = new Cache(); 
const segment = cache.segment(); 
const entity = await segment.put('Name', 'Linda McCartney',1); //Expiry time for cache in hours
console.log(entity);

Example of Expected Response

copy
{
  "cache_name": "Last_Name",
  "cache_value": "Smith",
  "project_details": { "project_name": "AlienCity", "id": "2136000000007733" },
  "segment_details": { "segment_name": "DataStore", "id": "2136000000008572" },
  "expires_in": "Aug 18, 2021 06:46 PM",
  "expiry_in_hours": "48",
  "ttl_in_milliseconds": "172800000"
}

Last Updated 2026-07-02 14:51:41 +0530 IST