How to use memory cache in Node.js?

One of the best ways to improve application performance is to configure the caching on the server. Let’s use the memory-cache plugin and we will configure the cache on Node.js server.

First, we need to install the memory-cache plugin and save it to the Node.js application.
npm install memory-cache --save


Then we can simply configure the plugin and test the set and get the cache values as below.
var cache = require('memory-cache');

cache.put('key', 'value');
cache.get('key');

That’s it. I hope this will help. 🙂
Ref: https://www.npmjs.com/package/memory-cache
Photo: https://www.brandeps.com

One Reply to “How to use memory cache in Node.js?”

Leave a Reply

Your email address will not be published. Required fields are marked *