Redis is an in-memory data structure store, used as a database, cache, and message broker that allows for incredibly fast read and write ops.
We are going to see 3 ways of setting up Redis. I will be using Ubuntu 20.04 for this tutorial.
Installing docker on
sudo apt update sudo apt install redis-server
You need to configure a couple of thing after this, use any editor and change the
supervised directive to
sudo nano /etc/redis/redis.conf
You can also set your redis password, since Redis is pretty fast you need a very strong password. Use the following command to generate one.
openssl rand 60 | openssl base64 -A
Save the files and restart the Redis service to check if its running.
sudo systemctl restart redis.service sudo systemctl status redis
Pull the Redis docker image
docker pull redis
And start a redis instance
docker run --name some-redis -d redis
You can also use a free tier instance from Redis Labs.
I'm gonna select the 30 MB free tier, that's more than enough for our project.
You will be directed to set up a database:
A few things to consider here:
- Type of eviction policy (I highly recommend setting up an eviction policy).
- If you want to use a Redis module, you can set it up here.
This blog is part of a series, in the next part, we will set up our node server to cache data with Redis. You can continue with the series using any of the Redis setups mentioned in this blog.