Skip to main content

Cache Store

The Cache Store is available in all Function and Scripts.

This allows for storing small data, objects, values on the server that can be read to later by another flow instance.

/**
* Gets an JSON string from the cache store.
* @param {string} key - The name of the object to get.
* @returns {string} - The value of the object as a JSON string.
*/
GetJson: function(key:string) { },

/**
* Sets an object in the cache store.
* @param {string} key - The name of the object to set.
* @param {object} value - The value of the object.
* @param {int} minutes - The number of minutes to keep this object in the cache for.
*/
SetObject: function(key:string, value, minutes: number) { },

/**
* Sets an JSON string in the cache store.
* @param {string} key - The name of the object to set.
* @param {string} json - The json to store
* @param {int} minutes - The number of minutes to keep this object in the cache for.
*/
SetJson: function(key:string, json: string, value:number) { }

Example

var cached = CacheStore.GetJson('test_object');
if(cached)
{
Logger.ILog('Got test_object in cache!');
let obj = JSON.parse(cached);
Logger.ILog('Obj.a: ' + obj.a + ' ' + typeof(obj.a));
Logger.ILog('Obj.b: ' + obj.b + ' ' + typeof(obj.b));
Logger.ILog('Obj.c: ' + obj.c + ' ' + typeof(obj.c));
Logger.ILog('Obj.c.d: ' + obj.c.d + ' ' + typeof(obj.c.d));
return 2;
}

Logger.ILog('Object not in cache, storing');
CacheStore.SetObject('test_object', {
a: 'string',
b: 123,
c: {
d: 'a object'
}
});

return 1;