using map to cache for around 5000 entries in Javascript apllication VS Redis

我们两清 提交于 2021-01-29 20:49:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!