Skip to content
GitHubXDiscordRSS

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.

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",
});

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"],
});

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,
});

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,
});

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",
});