Data & Architecture
Redis for cache, jobs and sessions
Redis keeps data in memory and responds accordingly fast. We use it for caches, sessions, rate limits, queues and distributed locks. The real work is in the details: which keys, how long they stay valid, and what happens when permissions change.
Redis is an in-memory data store with data types such as lists, hashes and streams, well suited for caching, queues and locks.
Data flow
How Redis fits into your processes
- Application
- Redis
- Database
- Worker
- Result
Use cases
What we build with Redis
Caching
Cache expensive queries, with clear rules for invalidation.
Jobs and queues
Process background tasks like document parsers reliably.
Rate Limits
Limit requests per user or interface and catch abuse.
Sessions and Pub/Sub
Share sessions between servers and distribute events live.
Typical projects
Why companies bring us in
- 01
Fast portal pages with permissions
- Starting point
- A portal recalculates data and permissions on every request, so pages load noticeably slowly.
- Solution
- We cache results per tenant and permission state and invalidate selectively when data or permissions change.
- Result
- Pages load faster, and after a permission change no one sees outdated content.
- 02
Process documents in the background
- Starting point
- Uploaded documents should be extracted without the user having to wait for the result.
- Solution
- We put tasks in a queue; workers process them with retries and a dead-letter store.
- Result
- Uploads are confirmed immediately; faulty documents are not lost and can be reprocessed.
- 03
Protect interfaces from overload
- Starting point
- A public API is flooded with requests by individual clients.
- Solution
- We implement rate limits per key and time window in Redis and return clear error messages.
- Result
- Individual clients no longer slow down the service for everyone else.
From practice
Redis in our projects
- Caching and permission checks in the portal of a commodities data platform.
- Jobs and cache of a property management platform.
- Queues for document parsers on a commercial real estate platform.
Approach
How we introduce Redis
- 1
Clarify the use case
Cache, queue or session store: each role needs different settings.
- 2
Keys and TTLs
Define naming scheme, expiry times and invalidation.
- 3
Integration
Integration in the application, with a fallback if Redis is unreachable.
- 4
Operations
Set up memory, persistence, replication and monitoring.
Result
What you get from us
- Key schema with namespaces and TTLs
- Cache layer with targeted invalidation
- Queues with retries and a dead-letter queue
- Rate limits per user or interface
- Distributed locks for critical processes
- Operation with persistence, replication and monitoring
import { createClient } from "redis";
const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();
// Mandant und Rechtestand im Schlüssel: nach einer Rechteänderung greift der alte Eintrag nicht mehr
export async function cached<T>(tenant: string, rightsVersion: number, key: string, load: () => Promise<T>): Promise<T> {
const k = `cache:${tenant}:r${rightsVersion}:${key}`;
const hit = await redis.get(k);
if (hit !== null) return JSON.parse(hit) as T;
const value = await load();
await redis.set(k, JSON.stringify(value), { EX: 300 });
return value;
}
Quality
What we watch for with Redis
- 1
Permissions in the key
A cache key without the tenant or permission state can serve someone else's data, so both belong in it.
- 2
Plan invalidation
We define upfront which event invalidates which entry instead of just relying on expiration times.
- 3
Memory limit
We set a memory limit with a suitable eviction policy so Redis does not grow uncontrollably.
- 4
Locks with expiry
Every lock gets an expiry time so a crashed process can't block anything permanently.
- 5
Cache separate from queue
Cache data may be evicted, jobs may not. We separate the two by configuration or instance.
Related
Often combined with
Redis
Common questions
Tap a question.
