Best way to cache in Node.js

I am trying to find the best caching solution for a node application. There are several modules that can manage this. Most popular: https://www.npmjs.com/package/node-cache

But I found that the answers are faster if I just save some results in a variable, for example:

var cache = ["Kosonsoy","Pandean","Ḩadīdah","Chirilagua","Chattanooga","Hebi","Péruwelz","Pul-e Khumrī"];

Then I can update this variable at a fixed interval, is it also classified as caching? Are there any known issues / issues for this method. Because it defiantly provides the fastest response times.

+4
source share
2 answers

, , . , .

, . , - Redis .

, , .

var cache = ["Kosonsoy","Pandean","Ḩadīdah","Chirilagua","Chattanooga","Hebi","Péruwelz","Pul-e Khumrī"];

.

.

var cache = {"Kosonsoy":data,"Pandean":moreData,...};

,

var storedValue = cache["Kosonosoy"];

cache[key] = value;
+2

, , .

, . .

+1

Source: https://habr.com/ru/post/1568522/


All Articles