Cache.put(options)
Method Description |
Puts a value into the cache. If the value provided is not a string, the system uses JSON.stringify() to convert the value to a string.
Note:
You can also put a value into the cache by using the Cache.get(options) method with its |
Returns |
void |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
1 unit |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2016.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required |
The key corresponding to the value to be placed in the cache. This value cannot be null. For example, a ZIP code can used as the key for city names. The maximum length of a key is 4KB (4096) bytes. |
|
string |
required |
The value to place in the cache. If the value is not a string, the system uses JSON.stringify() to convert the value before it is placed in the cache. The maximum size of the value is 500KB. |
|
number |
optional |
The maximum duration, in seconds, that the value may remain in the cache. Note that the value may be removed before the The minimum value is 300 (five minutes) and there is no maximum. The default
Important:
A cached value is not guaranteed to stay in the cache for the full duration of the |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/cache Module Script Samples.
//Add additional code
...
var myCache = cache.getCache({
name: 'temporaryCache',
scope: cache.Scope.PRIVATE
});
myCache.put({
key: 'keyText',
value: 'valueText',
ttl: 300
});
...
//Add additional code