Retrieve Data from the CacheAdmin Scope
Get Cache Value
Using the getValue() SDK method, you can retrieve the value of a Cache item from a segment. You must pass the key name as the argument. The promise returned here will be resolved to a String, which is the actual value of the key.
The segment reference used in the code snippet below is the segment instance.
//Get cache value by passing the key name
const cache = new Cache();
const segment = cache.segment();
const entity = await segment.getValue('Age');
console.log(entity);
Get Cache Object
You can retrieve the details of the cache where the key-value pair is of the object type. The key object is retrieved using the get() method where the key name is passed as an argument. The promise returned from this code will be resolved to an object which is a JSON.
The segment reference used in the code snippet below is the segment instance.
//Get Cache object by passing the key name as argument
const cache = new Cache();
const segment = cache.segment();
const entity = await segment.get('Age');
console.log(entity);
Example of Expected Response
{
"cache_name": "Name",
"cache_value": "Amelia Burrows",
"project_details": { "project_name": "AlienCity", "id": "2136000000007733" },
"segment_details": { "segment_name": "DataStore", "id": "2136000000008572" },
"expires_in": "Aug 18, 2021 06:39 PM",
"expiry_in_hours": "47",
"ttl_in_milliseconds": "172727000"
}
Last Updated 2026-07-02 14:51:41 +0530 IST
Yes
No
Send your feedback to us