What is Redis is an in-memory data structure store which can be used as a database, a cache and a message broker. Redis supports different data structures such as strings, lists, sets, hashes, bitmaps and etc. . Simply Redis uses you RAM to store data which is very fast, however if you reboot your server the values are gone, unless you enable R . Good news by default Redis enables persistence mechanism for you (you can disable or configure persistence according to your needs.) Redis edis persistence Install Redis (Linux) Refer: https://redis.io/download Download, extract and compile Redis with: $ wget http://download.redis.io/releases/redis-4.0.9.tar.gz$ tar xzf redis-4.0.9.tar.gz$ cd redis-4.0.9$ make The binaries that are now compiled are available in the _src_ directory. Run Redis with: $ src/redis-server You can interact with Redis using the built-in client: $ src/redis-cliredis> set foo barOKredis> get foo"bar" OK, now we have successfully installed Redis on the local machine. you can see useful that we can use with Redis. They are super simple and helpful. Spend some time with those commands. Here commands Using Redis in your NodeJS application First you need to install the Redis client for NodeJS via . npm npm install redis Now create a file called redisDemo.js in your NodeJS project. // redisDemo.jsvar redis = require('redis');var client = redis.createClient(); // this creates a new client By default redis.createClient() will use 127.0.0.1 and port 6379. If you have a customized ip and and a port use var client = redis.createClient(port, host); Now, we want to listen for the event to see whether we successfully connected to the redis-server. We can check for a successful connection like this. connect client.on('connect', () {console.log('Redis client connected');}); function Likewise, we want to check if we failed to connect to the redis-server. Well we can listen for the event for that. error client.on('error', (err) {console.log('Something went wrong ' + err);}); function This might trigger when you forget to start the before application is run. So make sure to run the redis server before testing this code. redis-server Note: you can start, stop the redis server using following commands. /etc/init.d/redis-server stop/etc/init.d/redis-server start Let’s see how our code looks like now. redis = require('redis'); client = redis.createClient(); var var client.on('connect', () {console.log('Redis client connected');}); function client.on('error', (err) {console.log('Something went wrong ' + err);}); function Now, Let’s see how to set some simple value under a key in redis. You can use set() and get() methods for that. client.set('my test key', 'my test value', redis.print);client.get('my test key', (error, result) { (error) {console.log(error); error;}console.log('GET result ->' + result);}); function if throw in client.set() we first give the key and then the value. Remember Redis is a key-value store. Redis will create a key named and assign the value for that key. ‘my test key’ ‘my test value’ You see that I’ve used that on set() method. well it prints “Reply: OK” to the console saying that redis saved the value. you can omit that argument if you want. redis.print Now in get() method we simply retrieve the value we just saved by specifying the exact key name. Then it will print the saved valued in the console. Let’s see the complete code now. redis = require('redis'); client = redis.createClient(); var var client.on('connect', () {console.log('Redis client connected');}); function client.on('error', (err) {console.log('Something went wrong ' + err);}); function client.set('my test key', 'my test value', redis.print);client.get('my test key', (error, result) { (error) {console.log(error); error;}console.log('GET result ->' + result);}); function if throw The output will look like this Redis client connectedReply: OKGET result ->my test value Conclusion Redis is very powerful in-memory data-store that we can use in our applications. It’s very simple to save and get data without much overhead. refer for more use cases and refer for more redis commands. https://www.npmjs.com/package/redis https://redis.io/commands