Get started

Key-value (Valkey)

keel.run runs serverless Valkey, the open-source, Redis-compatible key-value store. Each database runs in your environment and is reached through keel's gateway in two ways:

  • RESP over TLS on port 6379 — any Redis client (rediss:// URL).
  • REST — compatible with the Upstash REST API, so @upstash/redis works with a custom URL. Useful from edge and serverless runtimes that can't keep TCP connections.

Plans

Plan Memory Notes
kv-s 256 MB default
kv-m 1 GB
kv-l 4 GB Pro plan

The eviction policy is noeviction (writes fail when memory is full, default) or allkeys-lru (use it as a cache). Data is persisted to its volume (append-only file, written every second).

Create and connect

keel kv create cache --plan kv-s --eviction allkeys-lru
keel kv url cache            # rediss:// URL with password
keel kv url cache --rest     # REST URL and token
keel kv list

Link the database to a service and keel.run sets REDIS_URL, KV_REST_API_URL and KV_REST_API_TOKEN as secret variables and redeploys it. Apps inside keel.run reach the database through the in-cluster gateway (keel kv url cache --internal).

import { Redis } from '@upstash/redis';

const redis = new Redis({ url: process.env.KV_REST_API_URL!, token: process.env.KV_REST_API_TOKEN! });
await redis.set('greeting', 'hello');

Tokens and passwords can be rotated at any time; linked services are updated and redeployed.

Commands and limits

Administrative and dangerous commands (CONFIG, DEBUG, MODULE, SHUTDOWN, REPLICAOF, MIGRATE, and FLUSHALL unless you allow it) are blocked, also inside Lua scripts. KEYS and FLUSHDB are rate-limited. Request sizes, command rates and connections are limited per plan.

Preview environments

You cannot create KV databases in a preview environment yourself. Instead, every preview of a pull request gets an empty KV database for each one of its base environment, with the same name, on kv-s and with its own password and token. Linked variables point at it; production data and credentials never reach the preview. Preview KV databases do not count against your plan's database limit, are billed like other KV databases and are deleted with the preview. See preview environments.

Sleeping databases

A database without requests for 24 hours goes to sleep: its data stays on the volume and it costs only storage. The next request wakes it; the gateway holds that request for up to 10 seconds while it starts.

Billing

You pay per command, for the volume, and for the plan's memory while the database is awake. See pricing for the current prices.

View as Markdown