Skip to content

sharedCache.getValue

Signature: sharedCache.getValue(key, namespace*, global*, persist*)

Returns: Object value - the object retrieved from cache

Get an object from the thread-safe cache.

When no namespace is specified, the value is only accessible from inside the channel in which it was set. When a namespace is specified, the value is accessible to all channels in the same zone as the channel in which it was set. When global is set to true, the value is accessible to all channels across all zones.

Note

When global is set to true, namespace becomes a required field.

Parameters

Type Name Description Default
String key a unique string used to identify the cached value
String namespace* (optional) a unique string used to limit the scope of the value Channel ID
Boolean global* (optional) specifies whether or not the value is stored in the global cache false
Boolean persist* (optional) specifies whether or not the value is stored in the database false

Example

// Example: Retrieve a value from the shared cache by key.

// Populate the shared cache
var hashMap = new java.util.HashMap();
hashMap.put("Today", new java.util.Date(qie.getSystemTimeMilliseconds()));
hashMap.put("Jon's Bday", qie.deduceDate("2001-09-17"));

sharedCache.setValue(
    "the map", // key
    hashMap,   // value
    600        // TTL (seconds)
);

// Retrieve the cached value
var mapRetrieved = sharedCache.getValue("the map"); // Object (HashMap)

// Access values from the retrieved object
var today = mapRetrieved.get("Today");
var birthday = mapRetrieved.get("Jon's Bday");