datasource.cacheSet
Stores a value in the server-wide in-memory cache.
Shared and in memory
The cache is held in memory, so everything in it is lost when the server restarts. It's also shared by every process on the server, so give keys a prefix that won't clash with other processes, such as your process name.
js
datasource.cacheSet(key, value, durationMillis)Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The key. |
value | string | The value to store. Only strings are stored, so use JSON.stringify for objects. |
durationMillis | number | Optional. How long to keep the value, in milliseconds. 0 or left out keeps it until it's removed or the server restarts. |
Examples
js
datasource.cacheSet("exchangeRates", JSON.stringify({ AUD: 1.52 }), 3600000); // Keep for an hour
datasource.cacheSet("lastRunId", "12345"); // Keep until removed