Sometimes even Redis is too slow. So we cache his requests in NodeJS.
Project uses Docker
and has Makefile
. You can run plain JS, if you prefer, or run out-of-the-box Dockerized setup.
- Configure settings in
.env
file.
# default values:
PORT=3000
REDIS_ADDR=127.0.0.1
REDIS_PORT=6379
CACHE_EXPIRY_TIME=3600
CACHE_CAPACITY=10000
- Install Node packages and build app.
npm i
npm run start # in dev mode
- Run built version
npm run build
node dist
- Test:
curl localhost:3000/test1
curl localhost:3000/test1
curl localhost:3000/test2
- Setup environment variables for Docker compose:
# docker-compose.yml
...
environment:
- PORT=3000
- REDIS_ADDR=host.docker.internal
- REDIS_PORT=6379
- CACHE_EXPIRY_TIME=3600
- CACHE_CAPACITY=10000
- NODE_ENV=production
...
- Run Docker containers:
make
- Run tests
make test
Feel free to comment
[LICENSE]
MIT