Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add upstash-redis driver #289

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tmp
/test.*
__*
.vercel
.env
30 changes: 30 additions & 0 deletions docs/content/6.drivers/upstash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Upstash Redis

The `redis-upstash` driver is an [Upstash](https://upstash.com/) based HTTP only driver that can be used in environments where TCP isn't available.

```ts
import { createStorage } from "unstorage";
import redisUpstashDriver from "unstorage/drivers/redis-upstash";

const storage = createStorage({
driver: redisUpstashDriver({
base: "unstorage",
url: "https://your-upstash-db.com",
token: "your-token",
}),
});
```

**Options:**

- `url`: Url of your upstash redis database. This will default to the value of the `UPSTASH_REDIS_REST_URL` environment variable if not provided.
- `token`: Authorization token. This will default to the value of the `UPSTASH_REDIS_REST_TOKEN` environment variable if not provided.
- `base`: Optional prefix to use for all keys. Can be used for namespacing. Has to be used as hastag prefix for redis cluster mode.
- `envPrefix`: Optional prefix for your environment variables. Defaults to `UPSTASH_REDIS_REST`.
- `ttl`: Default TTL for all items in **seconds**.

See [upstash driver docs](https://github.com/upstash/upstash-redis) for all available options.

**Transaction options:**

- `ttl`: Supported for `setItem(key, value, { ttl: number /* seconds */ })`
Loading