sudo apt update
sudo apt install redis-server -yEnable Redis to start automatically
Edit the redis config:
sudo nano /etc/redis/redis.confChange the following line
change supervised no to supervised systemd
Save and exit
Open Redis CLI
redis-cliTest
127.0.0.1:6379> ping
PONG
The following repository contains the performance of api using redis . We generally see the response time of request with both caching and no-caching
git clone https://github.com/uchiha-vivek/Redis-concepts.gitcd Redis-conceptsInstall the dependencies
npm installRun the file
node index.jsOnce the server is running
Call cached endpoint (first time hit's miss)
curl "http://localhost:3000/photos?albumId=1"call cached endpoint again(hits)
curl "http://localhost:3000/photos?albumId=1"Invoke no-cache endpoint
curl "http://localhost:3000/photos-nocache?albumId=1"Test and check the metrics:
curl "http://localhost:3000/metrics"
The following data structures have been included:
- List
- String
- Set
- Sorted Set
- Hash
- JSON
Ways to test it
Navigate to data-structures folder
Run node structure.js
Test the following below api's
List
http://localhost:3000/api/v1/listString
http://localhost:3000/api/v1/stringSet
http://localhost:3000/api/v1/setSorted Set
http://localhost:3000/api/v1/zsetHash
http://localhost:3000/api/v1/hashJSON
http:/localhost:3000/api/v1/json
