Skip to content

Set

Stores an object in the cache.

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

Stores an object in the cache with a specified expiration duration.

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

Parameters

string key
    The key to associate with the value.

object value
    The value to be stored.

string duration
    The expiration duration in "day.hh:mm:ss" format. Optional.

Remarks

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

Storing an object in the cache:

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

If a duration is not specified, the object is stored indefinitely until the cache is cleared.
Specifying null as the value removes the object from the cache.

Storing an object in the cache with a duration:

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

See Also