Addons
Extend your egg with managed services that run alongside your app.
Redis Cache
Redis is available as a free sidecar addon for all eggs. It provides ephemeral in-memory caching, sessions, and pub/sub — no external server needed.
Enable Redis
Add Redis to your egg using the CLI:
hatch redis add Connecting to Redis
Once enabled, your app receives the REDIS_URL environment variable automatically:
REDIS_URL=redis://localhost:6379Redis runs as a sidecar in the same network as your app. Connect to localhost:6379 — no authentication needed.
Limits
Redis addon runs with the following constraints:
- 25 MB memory (allkeys-lru eviction when full)
- 50 max connections
- No persistence — data is lost on restart
- Starts and stops with your egg
Use Cases
Redis is ideal for:
- Session storage — store user sessions for fast access
- Caching — cache API responses, database queries, or computed values
- Pub/Sub — real-time messaging between app instances
- Rate limiting — track request counts per user or IP
Important: Redis data is ephemeral. Do not use it as your primary database. Data is lost when your egg restarts or sleeps.
Dashboard
You can also manage Redis from the dashboard under the Addons tab of your egg.
Check Redis Status
hatch redis info Example Usage (Node.js)
const Redis = require('ioredis');
const redis = new Redis(process.env.REDIS_URL);
// Cache a value
await redis.set('key', 'value', 'EX', 3600);
const value = await redis.get('key');
// Pub/Sub
const sub = new Redis(process.env.REDIS_URL);
sub.subscribe('events');
sub.on('message', (channel, message) => {
console.log(`${channel}: ${message}`);
});
await redis.publish('events', 'hello world');