Cache object method · N/cache

put()

Cache.put(options)

Puts a value into the cache.

Implementation
Not started
Design
Open for proposals suggest how it should read
Proposals
A
Signature
Cache.put(options)
Module
N/cache
Returns
string
Governance
1 unit
Script types
Server scripts
Version
SuiteScript 2.x, documented for 2.1; since NetSuite 2016.2
call shapefrom Oracle's parameter table
1objCache.put({2    key:   /* string, required */,3    value: /* string, required */,4    ttl:   /* number, optional */5});
Oracle reference for this method
ParameterTypeRequiredDescription
options.keystringrequiredThe 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.
options.valuestringrequiredThe 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.
options.ttlnumberoptionalThe maximum duration, in seconds, that the value may remain in the cache. Note that the value may be removed before the ttl limit is reached. The minimum value is 300 (five minutes). If this option is not specified, there is no default maximum value. Important: A cached value is not guaranteed to remain in the cache for the full duration of the ttl value. The ttl value represents the maximum time that the cached value may be stored. Cached data is not persistent, so you should consider using the Cache.get(options) method with the options.loader parameter to set and retrieve data.
B

No Mynt syntax yet.

Nothing in the language compiles to Cache.put(options) today. How should it read?

C

Competing syntax for put, from GitHub Discussions. Select two or more to compare them side by side.

All discussions

Loading proposals from GitHub…

D

Write the Mynt you wish you could write.

A good proposal shows the syntax, the SuiteScript it should become, and argues for it: why it is clearer, how it fits the rest of the language, what it makes harder.

  • Clarity. Does it say what happens, without ceremony?
  • Consistency. Does it read like load, save and Ref[field]?
  • Expressiveness. Does it cover the cases people actually write?
  • Honesty. Does it hide a NetSuite cost, such as governance, that a reader should see?

N/cache · Cache.put(options)

Suggest syntax for put