Back to technologies

Redis

Redis stores and retrieves data in memory. It can hold frequently requested results or short-lived values such as counters.

What you can build or improve

Frequently requested summaries

Store a calculation temporarily so several people can see the same result without running it each time.

Request limits

Keep a counter over a time window so the app can limit repeated attempts at an action.

When we’d choose it

We’d evaluate it when several people request the same report and recalculating it on every visit slows the system down.

Why use it

We can save a copy of the result for a set period. While that copy is valid, the app can respond without repeating an expensive query.

What to consider

Decide when cached data expires, how to update it when the original changes, and what happens if Redis stops responding. In this setup, the primary database keeps the authoritative record.

Illustrative example

Daily operations summary

Several supervisors open the same dashboard during the morning. The server reuses the recent summary and recalculates it when the copy expires.

Official documentation

Tools and how they fit together

Redis is useful when you know what it stores, how long that data lives, and what the system does when it goes away.

Temporary results

Temporary results

Use a key that identifies the report and branch. Set an expiry and read from the original data source when the cached copy is missing.

  • Redis Strings
  • TTL
Counters and limits

Counters and limits

A counter can help limit repeated attempts. Coordinate the increment and expiry window so concurrent requests don’t leave a counter without an expiration.

  • Redis INCR
  • Redis Lua scripts
Memory and operations

Memory and operations

Monitor memory use and decide what can be evicted when it fills up. If Redis holds data you can’t lose, assess persistence separately.

  • Redis INFO
  • maxmemory

Questions before you decide

How do we decide when a value expires?

Agree on how much delay is acceptable. A daily summary can tolerate a delay that might be unacceptable for booking availability.

Does it replace PostgreSQL?

For records like orders, we usually keep the source of truth in PostgreSQL. Redis can speed up specific reads without taking over that role.

What if Redis stops responding?

For a cache, fall back to the original data source with limits that protect it. For an access or rate limit, decide whether the operation should be blocked.

What technology fits your project?

Tell us your idea