- Print
- DarkLight
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Description
Inserts an object into cache, persisting for the lifetime of your app or until cleared.
Input Parameters
Name | Type | Required | Description |
---|---|---|---|
key | Text | Yes | Unique object identifier |
value | Any | Yes | Object to store |
Returns
No return value.
Examples
// store numeric value in cache
cache.set("score", 64);
// prepare a custom person object
var person = {
"firstName": "Caleb",
"age": 25,
"id": system.newId()
};
// store person object in cache
cache.set("myPerson", person);
// later, we can get same person from 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 store information across 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.