Documentation Index

Fetch the complete documentation index at: https://docs.doc-know.com/llms.txt

Use this file to discover all available pages before exploring further.

get

Prev Next

cache.get

Returns an item from cache (null if doesn't exist).

Input Parameters

Name Type Required Description
key Text Yes Unique item identifier
[default] Any No Default value to use if value doesn't exist

Returns

Type: Any

Returns the specified item from cache or null if it does not exist or is empty.

If a default value is specified and the item doesn't exist, then the default value is inserted into the cache and returned as the value. This offers a simple way to avoid checking if an item exists before retrieving it.

Examples

// get score value from cache
// returns null if doesn't exist
var score = cache.get("score");
// get score value from cache
// returns a default value of 85 if doesn't exist
var score = cache.get("score", 85);
// get person object from cache
// we assume a person object was previously inserted into cache
var person = cache.get("myPerson");

// print person's first name to the debug console
debug.log(person.firstName);

Remarks

Use this function when you want to retrieve information that has been stored into cache from previous script executions.

Definition

Cache is a programming term referring to a simple database of information. A cache is a collection of associated key-value pairs. The key must be a unique identifier and the value is any object you want to store. Once stored, you can retrieve these objects using their keys.