|
1 | 1 | # SRH: Serverless Redis HTTP |
2 | | -A redis connection pooler for serverless applications. This allows your serverless functions to talk to Redis via HTTP, |
| 2 | +A Redis connection pooler for serverless applications. This allows your serverless functions to talk to Redis via HTTP, |
3 | 3 | while also not having to worry about the Redis max connection limits. |
4 | 4 |
|
5 | | -Totally open source so you still own the data - run it with your own Redis server. |
| 5 | +The idea is you host this alongside your Redis server, so minimise latency. The serverless functions can then talk to |
| 6 | +this via HTTP. |
6 | 7 |
|
7 | | -I will also offer some kinda SaaS version when it's a bit more done ;) - but still BYOR (bring your own Redis)! |
| 8 | +## Features |
| 9 | +- Allows you to talk to redis via HTTP |
| 10 | +- Pools redis connections |
| 11 | +- Automatically kills redis connections after inactivity |
| 12 | +- Supports multiple redis instances, and you can configure unique tokens for each |
| 13 | +- Fully supports the `@upstash/redis` TypeScript library. |
8 | 14 |
|
9 | | -Don't use this yet - it's still in development. |
| 15 | +## Client usage |
| 16 | +This will not work with regular Redis clients, as it is over HTTP and not the redis protocol. |
| 17 | +However, to try and keep the project as "standardised" as possible, you can use the `@upstash/redis` TypeScript library. |
| 18 | +You can read about it here: [Upstash Redis GitHub](https://github.com/upstash/upstash-redis) |
10 | 19 |
|
11 | | -Also, it's totally compatible with the Upstash Redis Client SDKs. |
| 20 | +Soon I will add specific documentation for the endpoints so you can implement clients in other languages. |
| 21 | + |
| 22 | +## Installation |
| 23 | +Soon, I will provide a Docker container for this. Right now, you need Elixir 1.13+ installed. Clone down the repo, then run: |
| 24 | +`mix deps.get` |
| 25 | +then |
| 26 | +`iex -S mix` |
| 27 | + |
| 28 | +To configure Redis targets:\ |
| 29 | +Create a file: `srh-config/tokens.json` |
| 30 | +```json |
| 31 | +{ |
| 32 | + "example_token": { |
| 33 | + "srh_id": "some_unique_identifier", |
| 34 | + "connection_string": "redis://localhost:6379", |
| 35 | + "max_connections": 3 |
| 36 | + } |
| 37 | +} |
| 38 | +``` |
| 39 | +Notes: |
| 40 | +- Srh_id can be anything you want, as long as it's a string, and unique. |
| 41 | +- `max_connections` is the maximum number of connections for the pool. |
| 42 | + - If there is inactivity, the pool will kill these connections. They will only be open while the pool is alive. The pool will re-create these connections when commands come in. |
| 43 | +- You can add more redis instances to connect to by adding more tokens and connection configurations. Based on the header in each request, the correct pool/connection info will be used. |
0 commit comments