Skip to content

Set

Stores an object in cache.

1
$Cache.Set(key: string, value: object):void

Stores an object in cache with duration limit

1
$Cache.Set(key: string, value: object, duration: string):void

Parameters

string key
    Key of value

object value
    value to be stored

string duration
    Expiration duration. Optional.

Remarks

If duration is not specified, object is stored as indefinitely until cache is cleared.
Duration can be specified in "day.hh:mm:ss" format.
Specifying value as null removes object from cache.

How to store an object in cache

1
2
3
4
var id = 1;
$Cache.Set("myObject:" + id, {
 Name : 'Madonna'
});

If duration is not specified, object is stored as indefinitely until cache is cleared.
Duration can be specified in "day.hh:mm:ss" format.
Specifying value as null removes object from cache.

How to store an object in cache with duration

1
2
3
4
var id = 1;
$Cache.Set("myObject:" + id, {
  Name : 'Madonna'
}, "12:00:00");

See Also