https://github.com/stbestichhh/raito-cache
Simple caching proxy server CLI tool
https://github.com/stbestichhh/raito-cache
cache-proxy caching cli nodejs server
Last synced: 5 months ago
JSON representation
Simple caching proxy server CLI tool
- Host: GitHub
- URL: https://github.com/stbestichhh/raito-cache
- Owner: stbestichhh
- License: mit
- Created: 2024-11-24T13:02:19.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-10T07:12:53.000Z (about 1 year ago)
- Last Synced: 2024-12-10T08:20:28.553Z (about 1 year ago)
- Topics: cache-proxy, caching, cli, nodejs, server
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/raito-cache
- Size: 161 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/raito-cache)
[](https://github.com/stbestichhh/raito-cache/actions/workflows/node.js.yml)
[](https://github.com/ellerbrock/open-source-badges/)
[](LICENSE)
# Raito-Cache
## Table of contents
* [Description](#about)
* [Getting started](#getting-started)
* [Installation](#installation)
* [Command Line Interface](#cli)
* [Deployment](#deployment)
* [Contributing](#contributing)
* [Changelog](#changelog)
* [Authors](#authors)
* [License](#license)
## 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
```shell
$ yarn add -g raito-cache
```
#### 2. Run the server
```shell
$ raito --port 3000 --password raitopass
```
### CLI
**Start the server:**
```text
Usage: raito --port [options]
Lite caching proxy server
Options:
--port define port on which to start the server
--host define host on which to start the server (default: "localhost")
--ttl define time to live for the cache record in ms
-pass, --password define a password for the server to prevent non authorized connections
-v, --version output the version number
-h, --help display help for command
```
**App commands:**
* `status` - check server status
* `stop` - stop the server without exiting.
* `start` - start the server
* `exit` - stop the server and exit the process
* `clear-cache` - deletes all records
* `ttl ms` - time to live in milliseconds
* `get` - get cache.
* `get *` - get all records
* `get key` - get cache by key
* `get 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
1. Pull docker image:
```shell
$ docker pull stbestich/raito-cache:latest_amd64
```
2. Run it
```shell
$ docker run -e HOST= -e PASSWORD= -p :9180 -it stbestich/raito-cache
```
#### Use with docker-compose
```yaml
services:
raito-cache:
image: stbestich/raito-cache:latest
ports:
- "${PORT:-9180}:${PORT:-9180}"
- "${PORT:-9181}:${PORT:-9181" # Define second port if you need http proxy
env_file:
- .env
environment:
NODE_ENV: production
PORT: ${PORT:-9180}
HOST: ${HOST:-0.0.0.0}
TTL: ${TTL}
PASSWORD: ${PASSWORD}
tty: true
stdin_open: true
```
## Contributing
Please read [CONTRIBUTING.md](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](CHANGELOG.md).
We use [SemVer](https://semver.org/) for versioning.
For the versions available, see the [tags](https://github.com/stbestichhh/raito-cache/tags) on this repository.
For the versions supported, see the [SECURITY.md](SECURITY.md).
## Authors
- [@stbestichhh](https://www.github.com/stbestichhh)
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE)