Redis
Redis-compatible cache and data store on StackBlaze, served by Valkey, for caching, session storage, pub/sub, and job queues.
Powered by Valkey
Creating a Valkey instance
From the project canvas, click + Service → Databases → Valkey. Stage the add-on, then click Commit.
To attach it to an app, use the add-on's Connections list or the app's Add-ons tab. StackBlaze injects connection environment variables into the app. There is no Environment tab → Attach database flow. To inspect or add your own variables, use the app's Variables tab.
Injected environment variables
Valkey on StackBlaze is password-less. Attached apps receive:
| Variable | Role |
|---|---|
| REDISHOST | Instance hostname |
| REDISPORT | 6379 |
| REDIS_URL | redis://host:6379 |
redis://[host]:6379There is no password in the URL, and no TLS URL scheme. Use the injected REDIS_URL as-is.
Browse and query with CloudBeaver
Every database add-on ships with CloudBeaver. Open with DB Beaver on the add-on's Overview starts a scoped session where you can browse tables, run SQL, and edit data in the browser.
Common use cases
Caching (Node.js / ioredis)
import Redis from 'ioredis'
const redis = new Redis(process.env.REDIS_URL)
async function getUser(id: string) {
const cached = await redis.get(`user:${id}`)
if (cached) return JSON.parse(cached)
const user = await db.users.findById(id)
await redis.setex(`user:${id}`, 3600, JSON.stringify(user)) // TTL: 1 hour
return user
}Session storage (Express + connect-redis)
import session from 'express-session'
import { createClient } from 'redis'
import { RedisStore } from 'connect-redis'
const client = createClient({ url: process.env.REDIS_URL })
await client.connect()
app.use(session({
store: new RedisStore({ client }),
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: { secure: true, maxAge: 86400000 }, // 24 hours
}))Job queues with BullMQ
import { Queue, Worker } from 'bullmq'
const connection = { url: process.env.REDIS_URL }
// Producer: add jobs from your API
const emailQueue = new Queue('emails', { connection })
export async function sendWelcomeEmail(userId: string) {
await emailQueue.add('welcome', { userId }, {
attempts: 3,
backoff: { type: 'exponential', delay: 2000 },
})
}
// Consumer: process jobs in a worker service
const worker = new Worker('emails', async (job) => {
const { userId } = job.data
await mailer.sendWelcome(userId)
}, { connection })Pub/Sub (broadcasting across pods)
When you scale your web service horizontally, use Redis pub/sub to broadcast events across all running instances. This is especially useful for WebSocket servers that need to push to all connected clients.
import { createClient } from 'redis'
const publisher = createClient({ url: process.env.REDIS_URL })
const subscriber = publisher.duplicate()
await publisher.connect()
await subscriber.connect()
// Publish from any pod
await publisher.publish('notifications', JSON.stringify({ userId, message }))
// Subscribe on all pods
await subscriber.subscribe('notifications', (message) => {
const { userId, message: msg } = JSON.parse(message)
io.to(userId).emit('notification', msg) // Socket.IO broadcast
})Backups
Backups are not enabled automatically. Open the Valkey add-on, go to the Backups tab, and click Enable backups. From there you can use Backup now, Restore, and Schedule.
Valkey backups are RDB snapshots. Restore always creates a new instance — there is no in-place restore. After the new instance is ready, switch the app connection to it from the add-on Connections list or the app Add-ons tab.
For the full backup workflow, see Backups & recovery.
Eviction policy
When Valkey reaches its memory limit, it uses an eviction policy to decide which keys to remove. The default policy is typically allkeys-lru (evict least recently used keys first), which is appropriate for cache workloads.
For session storage or job queues where silent key loss is unacceptable, use a policy such as noeviction so the instance returns errors when memory is full rather than dropping keys.
Tip
REDIS_URL or the pair REDISHOST / REDISPORT. Do not add a password to the URL.Under the hood