Redis is a powerful tool for caching data and having it available in memory. Redis requires RAM to use, and every piece of data you use in Redis is loaded into the RAM. That means it can be accessed really quickly, which allows us to cache and provide data to users super fast. \ Redis has lots of uses, including caching web pages and as a normal database for quicker access. It also can be used out of the box with Node.JS. In this guide, I'll show you how to get started with Redis and Node.JS. ## Using Redis With Node.JS Before you start, make sure you [install Redis](https://fjolt.com/article/redis-how-to-install) first. Then start up a new Node.JS project/folder, and initiate `npm` using `npm init` in the folder: \ ``` npm init ``` \ This will guide you through the `npm` setup. You can then install the `npm` Redis package using: \ ``` npm i redis ``` \ After that, you're free to use `redis` in your code in whatever way you like. \ The Node.JS Redis package gives you an interface to store data in a Redis database, just like you would if you were using Redis from the command line. To get started with it, you can import Redis into your code like so: \ ```javascript import { createClient } from 'redis'; const client = createClient(); client.on('error', (err) => console.log('Redis Client Error', err)); await client.connect(); ``` \ `createClient` is the function we use to connect to Redis - after which we initiate our Redis connection by using the `connect()` method on that function. After that, we can interact with `redis` using our `client` variable. \ Let's look at some examples. To set a key, we can now use `client.set`: \ ```javascript await client.set('myKey', 'someValue'); ``` \ Since it takes a bit of time to set the data in RAM, each of these functions are `async` - meaning they return promises. So make sure you use them in conjunction with `await` or `then`. [You can learn more about promises here](https://fjolt.com/article/javascript-how-to-use-await-and-promises). \ Similarly, we can retrieve a key using `get`: \ ```javascript await client.get('myKey') ``` \ Redis is much faster than other databases since it's available right in the memory - so expect a high level of performance using these functions. You can also use any other typical redis function, like [Hashes](https://fjolt.com/article/redis-hashes): \ ```javascript await client.hSet('user', '1', 'someValue'); await client.hGetAll('user'); ``` \ You can also use `sendCommand` if you'd rather send a specific command of any kind to Redis. This is useful if you find something which Redis for Node.JS does not support: \ ```javascript await client.sendCommand(['HGETALL', 'someKey']); ``` ## Conclusion Redis is super fast, and I used it quite extensively to build [fjolt](https://fjolt.com/). I hope you've enjoyed this quick guide on getting started with Redis in Node.JS