If I want to create a HashMap in an M/R script to ...
# suitescript
c
If I want to create a HashMap in an M/R script to cache some lookup data (internal IDs), how big can the HasMap get before I have a governance issue? I could also consider using n/cache but I have no idea how quick that is compared to n/search or n/query. I'm using M/R scripts to import many transactions, and constant searches and queries for internal IDs have a large performance impact over a large volume.
e
That's a good question. I don't remember ever seeing any governance limits on JS object sizes. I've done something like this with N/cache but the amount of data was relatively small. I just created the data object in the getInputData stage and then put it in cache. One thing to note is that you can't guarantee the data to remain in cache so you need to account for that down in your map stage to reload if needed.
Retrieving from N/cache in the map stage should be significantly faster than doing search or query.
a
The script execution instance has a memory size limit, but I don't have those memorized. In my experience, N/cache is significantly faster than N/search and N/query, and in my mind that is one of the things that makes it useful.
c
I was also thinking of pre-warming the cache. Running a script to import all name/id pairs across customers, vendors, accounts, etc before running my imports.
Otherwise lazy load data into the cache after every search.
a
yeah you won't have a governance issue, you'll potentially run into memory limits but i think they're like 50MB which is huge if your data doesn't include like file binary blobs or w/e
and yeah cache retrieval is way faster than looking up the data... that's the whole point of a cache 😄
c
The concept of a cache and NetSuite's implementation of a cache could be two very different things 😄 I have implemented n/cache now, my next large data import will show how well it works.
j
N/cache values definitely have a limit, ask me how I know 😞 I recently had to replace a solution that used N/cache with having a file stored in the file cabinet that I periodically update using a Map/Reduce.