N/cache Module
Use the N/cache module to enable temporary, short-term storage of data. Using a cache improves performance by eliminating the need for scripts to repeatedly retrieve the same piece of data. You can use this module to build a cache to store and retrieve string values using a specific key.
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. Data is stored in the cache according to its time to live (ttl) specified in the Cache.put(options) method.
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 object exists, this method returns it. If the cache object does not exist, the system creates and returns a new 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
Set this value using the cache.Scope enum. |