问题
I have a PRICE_MAPPER table at my DB
It has around 5000 entries
Price is determined on 3 entry types
A B C ---> 300 (col1:A , col2:B , col3:C , colPrice:300)
X Y Z ---> 500
.. and around 5000 of such entries (3 unique combinations determining a price)
Planning to put these in a MAP at my Nodejs application
Concern: I need advice, putting such a heavy data at my Nodejs application, would that be good decision or bad, as Nodejs is not for memory intensive tasks.
I can cache this data at REDIS, but I want to avoid the network call involved in communication with Redis sever, for aiming lowest latency
回答1:
If you are going to have one single instance in your node.js application use internal memory to store your data.
However, be sure that if the process goes down, you have to put that data back to memory!
Using REDIS could be a good solution if you think that you will have multiple instances to read the same shared map from the memory and if there are simultaneous changes on that map.
来源:https://stackoverflow.com/questions/64382757/using-map-to-cache-for-around-5000-entries-in-javascript-apllication-vs-redis