Skip to content

Redis & Valkey

Stackpad provides managed Redis and Valkey instances as project services. Use them for caching, session storage, rate limiting, queues, and real-time features.

Creating a cache service

  1. Open your project in the dashboard
  2. Click Add Service → Cache
  3. Select Redis or Valkey
  4. Click Create

Both options include:

  • Persistent storage — data survives container restarts
  • Private network access at redis:6379 or valkey:6379
  • Automatic backups based on your plan

Redis vs. Valkey

Valkey is an open-source fork of Redis, maintained by the Linux Foundation. It’s fully compatible with Redis clients and commands.

RedisValkey
LicenseSource-available (SSPL)BSD-3 (fully open source)
CompatibilityDrop-in Redis replacement
PerformanceExcellentExcellent

Both work identically with any Redis client library. Choose Valkey if you prefer a fully open-source license.

Connecting from your application

Stackpad injects the REDIS_URL environment variable into your web services:

redis://redis:6379
// Using ioredis
import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_URL!);
await redis.set('key', 'value');
const value = await redis.get('key');
// Using @upstash/redis (works with any Redis)
import { Redis } from '@upstash/redis';
const redis = new Redis({ url: process.env.REDIS_URL! });

Common use cases

Session storage

import session from 'express-session';
import RedisStore from 'connect-redis';
import Redis from 'ioredis';
app.use(session({
store: new RedisStore({ client: new Redis(process.env.REDIS_URL!) }),
secret: process.env.SESSION_SECRET!,
}));

Caching

const cached = await redis.get(`user:${id}`);
if (cached) return JSON.parse(cached);
const user = await db.query.users.findFirst({ where: eq(users.id, id) });
await redis.set(`user:${id}`, JSON.stringify(user), 'EX', 3600);
return user;

What’s next?