UpstashRedis
Learn how to create and manage Upstash Redis databases with global replication.
The UpstashRedis component lets you create and manage Upstash Redis databases with global replication.
Minimal Example
Section titled “Minimal Example”Create a basic Redis database in a single region.
import { UpstashRedis } from "alchemy/upstash";
const redis = await UpstashRedis("my-redis", { name: "my-redis", primaryRegion: "us-east-1",});
With Read Replicas
Section titled “With Read Replicas”Create a Redis database with read replicas in multiple regions for global distribution.
import { UpstashRedis } from "alchemy/upstash";
const redis = await UpstashRedis("my-redis", { name: "my-redis", primaryRegion: "us-east-1", readRegions: ["us-west-1", "us-west-2"],});
With Monthly Budget
Section titled “With Monthly Budget”Create a Redis database with a specified monthly budget limit.
import { UpstashRedis } from "alchemy/upstash";
const redis = await UpstashRedis("my-redis", { name: "my-redis", primaryRegion: "us-east-1", budget: 100,});
With Eviction Enabled
Section titled “With Eviction Enabled”Create a Redis database with eviction enabled to automatically remove keys when memory is full.
import { UpstashRedis } from "alchemy/upstash";
const redis = await UpstashRedis("my-redis", { name: "my-redis", primaryRegion: "us-east-1", eviction: true,});
With Custom API Credentials
Section titled “With Custom API Credentials”Create a Redis database using custom API credentials instead of environment variables.
import { UpstashRedis } from "alchemy/upstash";
const redis = await UpstashRedis("my-redis", { name: "my-redis", primaryRegion: "us-east-1", apiKey: alchemy.secret(process.env.CUSTOM_UPSTASH_API_KEY), email: "custom@example.com",});