Redis Cloud
Use Redis for caching, session storage, and pub/sub messaging from your Spala flows.
Redis Cloud
The Redis Cloud addon connects your Spala flows to a Redis instance. Use it for caching frequently accessed data, storing session information, implementing rate limiting, and building real-time features with pub/sub messaging.
Installation
1. Enable the Redis Cloud addon from the Addons panel 2. Enter your Redis connection details in the addon configuration
Configuration
Available Steps
Redis Get
Retrieves a value by key.
Returns the stored value, or null if the key does not exist. JSON values are automatically parsed.
Redis Set
Stores a value with an optional expiration time.
Redis Delete
Deletes one or more keys.
Redis Increment
Atomically increments a numeric value.
Example: API Response Caching
// GET /api/products/featured
// Step 1: Redis Get // key: 'cache:featured_products' // Output → vars.cached
// Step 2: Condition - Cache hit // If vars.cached !== null // Step 3: Response → vars.cached
// Step 4: Database Query - Fetch from database // SELECT * FROM products WHERE featured = true ORDER BY created_at DESC LIMIT 20
// Step 5: Redis Set - Cache the result // key: 'cache:featured_products' // value: vars.products // ttl: 300 (5 minutes)
// Step 6: Response → { products: vars.products }
Example: Rate Limiting
// Middleware flow for rate-limited endpoints
// Step 1: Set Variable - Build rate limit key // vars.rateLimitKey = 'ratelimit:' + vars.auth.userId + ':' + vars.path
// Step 2: Redis Increment // key: vars.rateLimitKey // Output → vars.count
// Step 3: Condition - First request in window // If vars.count === 1 // Step 4: Redis Set - Set expiry on first request // key: vars.rateLimitKey, value: 1, ttl: 60
// Step 5: Condition - Over limit // If vars.count > 100 // Step 6: Response with 429 Too Many Requests
Example: Session Storage
// POST /api/auth/login
// ... authentication logic ...
// Step 1: Set Variable - Generate session token // vars.sessionToken = crypto.randomUUID()
// Step 2: Redis Set - Store session
// key: 'session:' + vars.sessionToken
// value: { userId: vars.user.id, email: vars.user.email, role: vars.user.role }
// ttl: 86400 (24 hours)
// Step 3: Response
// { token: vars.sessionToken }
Redis is ideal for data that needs fast access and can tolerate loss on restart (unless persistence is configured). For permanent data storage, use your PostgreSQL database.
Set TTL values on cache keys to prevent unbounded memory growth. Keys without a TTL remain in Redis indefinitely and can eventually exhaust available memory.
Redis connection URL (e.g., "redis://username:password@host:port"). The Redis key to retrieve. The Redis key. The value to store. Objects are automatically serialized to JSON. Time to live in seconds. The key is automatically deleted after this time. The key or array of keys to delete. The key to increment. Amount to increment by (default: 1). Addons Overview /addons Browse available addons Installing Addons /addons/installing Enable and configure addons in your project