Skip to content

Get

Retrieves a cached value by its key, if it exists.

$Cache.Get(key: string):( T | "null" )

Parameters

string key
    The key of the value to retrieve.

Returns

The cached value if found; otherwise, null.

Remarks

The key name can include a ":" qualifier if needed. Script keys are internally prefixed with Scripting:, isolating this surface from callers that use the underlying cache directly.

Values are JSON-serialized. Objects and arrays are returned as fresh script objects; recognized date-time strings are returned as DateTimeOffset values.

Getting a cached object

1
2
var id = 1;
var myObject = $Cache.Get('myObject:' + id);

See Also