N/cache Module
Use the N/cache module to enable temporary, short-term storage of data. Data is stored in the cache according to its time to live (ttl) specified in the Cache.put(options) method. You can use the this module to build a cache to store and retrieve string values using a specific key. The N/cache module is supported by all server script types.
Using a cache improves performance by eliminating the need for scripts in your account to repeatedly retrieve the same piece of data. You can create a cache that is available (1) to the current script only, (2) to all server scripts in the current bundle, or (3) to all server scripts in your NetSuite account.
In This Help Topic
N/cache Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Server scripts |
Encapsulates a cache which is a segment of memory that can be used to store data on a temporary, short-term basis. |
|
Method |
Server scripts |
Checks for a cache object with the specified name. If the cache exists, this method returns the cache object. If the cache does not exist, the system creates a cache and returns the created cache object. |
||
Enum |
enum |
Server scripts |
Holds the string values that describe the availability of the cache. Use this enum to set the value of the Cache.scope property. |
Cache Object Members
The following members are called on cache.Cache.
Member Type |
Name |
Return Type/Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Retrieves a value from the cache based on a key that you provide. If the requested value is not in the cache, the method calls the user-defined function identified by a method parameter. |
|
string |
Server scripts |
Puts a value into the cache. |
||
string |
Server scripts |
Removes a value from the cache. |
||
Property |
string |
Server scripts |
The name of the cache. |
|
string |
Server scripts |
The availability of the cache. A cache can be made available to the current script only, to all scripts in the current bundle, or to all scripts in your NetSuite account. Set this value using the cache.Scope enum. |