raito-cache
v1.0.0
Published
Lite caching proxy server
Downloads
364
Maintainers
Readme
Raito-Cache
Table of contents
About
raito-cache - is lightweight caching proxy server. This server intercepts requests, caches responses, and serves them from the cache, improving performance by reducing redundant network calls. It also includes command line interface with command handling functionality.
Getting started
[!IMPORTANT] Node.js 18.x+ version must be installed in your OS.
1. Install server
$ yarn add -g raito-cache
2. Run the server
$ raito --port 3000 --origin https://jsonplaceholder.typicode.com
3. Send request
$ curl http://localhost:3000/todos/1
{"userId":1,"id":1,"title":"delectus aut autem","completed":false}
now this response is cached on the server
CLI
Start the server:
Usage: raito --port <port> [options]
Lite caching proxy server
Options:
--host <host> define host on which to start the server (default: "localhost")
--origin <url> define url for caching
--http start a http server. Only websocket starts by default
--ttl <ms> define time to live for the cache record in ms
-v, --version output the version number
-h, --help display help for command
App commands:
status
- check server statusstop
- stop the server without exiting.start
- start the serverexit
- stop the server and exit the processclear-cache
- deletes all recordsttl ms
- time to live in millisecondsget
- get cache.get *
- get all recordsget key
- get cache by keyget HTTP_METHOD
- get all cached responses from HTTP_METHOD requests. Example:get POST
get :ROUTE
- get all cached responses from the specific route. Example:get :/tasks/2
get HTTP_METHOD:ROUTE
- get a specific cached response
set key data ttl
- create a new record with key and data. ttl - time to live for record (optional)help
- get all commands
Deployment
- Pull docker image:
$ docker pull stbestich/raito-cache:latest
- Run it
$ docker run -e HOST=<host> -p <port>:9180 -it stbestich/raito-cache
Use with docker-compose
services:
raito-cache:
image: stbestich/raito-cache:latest
ports:
- "${PORT:-9180}:${PORT:-9180}"
env_file:
- .env
environment:
NODE_ENV: production
PORT: ${PORT:-9180}
HOST: ${HOST:-0.0.0.0}
TTL: ${TTL}
tty: true
stdin_open: true
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Changelog
Project changes are writen in changelog, see the CHANGELOG.md.
We use SemVer for versioning. For the versions available, see the tags on this repository. For the versions supported, see the SECURITY.md.
Authors
License
This project is licensed under the MIT License - see the LICENSE.md