A Redis DB usage guide for a healthcare app has to answer three questions: why add Redis, what may be kept in it and for how long, and how to stop protected health information ending up in a shared cache or on disk. Redis is fast because it keeps data in memory, and that speed makes it easy to cache more than anyone intended.
Startup founders and enterprise product and engineering leaders adding Redis to a healthcare backend will find where it helps, what to cache, expiry and access rules, and the persistence settings that matter for PHI.
How should a healthcare app use Redis, and what may it cache?
A healthcare app should use Redis for short-lived, rebuildable data such as sessions, rate limits, job queues and reference data, and cache patient data only with short expiry times, separate key spaces and access controls. Agnotic Technologies keeps PHI out of shared caches by default and treats every cached patient value as a copy that must expire.
Adding Redis to a healthcare backend?
We decide what is cached, for how long and who can read it.
In most of these designs Redis is a cache, not the system of record. If a key disappears, the app rebuilds it from the database; if it cannot be rebuilt, it should not live only in Redis.
Why add Redis to a healthcare app at all?
Add Redis when the app repeats the same reads, needs shared state across servers, or needs fast counters and queues. Do not add it to hide a slow query before checking the query itself.
- Sessions shared across several application servers.
- Rate limits and lockout counters for sign-in and APIs.
- Background job queues, such as appointment reminders or report generation.
- Reference data that rarely changes: code lists, clinic hours, fee schedules.
- Results of expensive lookups that hold no patient data, such as a provider directory.
What may be cached, and what should stay out?
Cache data that is the same for many users or that holds no patient information, and keep clinical content out unless there is a measured reason and matching controls.
| Data | Cache in Redis? | Expiry | Notes |
|---|---|---|---|
| Reference data | Yes | Long, deleted on change | The same for every user |
| Session records | Yes | Matches the session timeout | User id and roles only, no patient data |
| Rate limit counters | Yes | The limit window | Keyed by user or IP, never by patient |
| Patient summary for a busy screen | Only with a reason | Short | Separate instance or key space, strict access |
| Clinical notes, results, documents | No | Not applicable | Read from the source system each time |
| Search results with patient names | No | Not applicable | A list of patients is PHI too |
How should expiry times be set?
Set an expiry on every key that holds anything derived from a user or a patient, at write time and in the same command. A key without an expiry stays until it is deleted or evicted, which may be never.
Redis documentation says the volatile eviction policies behave like noeviction when no keys have an expiration set, and that under noeviction the server returns an error to commands that add new data once the maxmemory limit is reached.
- Use SET with an expiry option rather than a separate EXPIRE call, so no key is ever written without one.
- Choose the expiry from how stale the data may safely be, not from how often it is read.
- Delete on change: when the source record changes, delete the cached copy instead of waiting for it to expire.
- Alert on keys without an expiry in key spaces that should never contain one.
How do you keep PHI out of shared caches?
Keep PHI out of shared caches by giving patient data, if it is cached at all, its own instance or key space with its own credentials, and by refusing it in caches other services use. Shared caches are read by more code than anyone tracks.
Redis documentation says that in the default configuration every new connection is authenticated as the default user, which needs no password and can call every command and access every key. ACL users can be limited to key patterns, such as ~cached:*, and to named commands.
- Separate instances for PHI and non-PHI where the budget allows; separate ACL users and key prefixes where it does not.
- One ACL user per service, limited to its key patterns and the commands it needs, with destructive and admin commands removed.
- No PHI in key names: a key that contains a patient's name or record number leaks it to anyone who can list keys or read logs.
- TLS between the application and Redis, with the instance reachable only from the private network.
What about persistence, replicas and backups?
Treat persistence as part of the PHI decision, because a cache that writes to disk has turned in-memory copies into files. Snapshots, replicas and backups need the same protection as the database.
Redis documentation says that by default Redis saves snapshots of the dataset on disk in a binary file called dump.rdb, and that persistence can be disabled completely, which is sometimes done when Redis is used as a cache.
- For a cache with no PHI, persistence is often unnecessary; for one that holds PHI, decide deliberately and document the choice.
- Encrypt the disks that hold snapshot or append-only files, and restrict who can copy them.
- Include replicas and backups in access reviews and in data deletion processes.
- Check what a managed Redis service does with snapshots and backups, and where it stores them.
What must not be logged around the cache?
Do not log cached values, full keys that contain identifiers, or the output of debugging commands in production. Cache problems tempt engineers to dump contents, and that dump becomes another copy of patient data in the log system.
- Log key prefixes, hit and miss counts and latency, never values.
- Restrict commands that stream every command the server receives, such as MONITOR, through ACLs.
- Keep production cache inspection behind an access process that is audited.
How should cache keys be designed?
Cache keys should name the kind of data and an opaque identifier, follow one pattern per service, and be easy to match in ACL rules. Good key design makes access control and deletion simple later.
- Prefix by service and data type, for example a scheduling prefix followed by a reference-data name.
- Use internal ids or hashes, never names, birth dates or record numbers.
- Include a version segment so a change in the cached shape does not read stale entries.
- Keep one prefix per data class, so a PHI key space can be granted, audited and flushed on its own.
What should happen when Redis is unavailable?
When Redis is unavailable, the application should fall back to the database for cached reads, keep security checks in place and protect queued work. Deciding this per use case stops a cache outage from turning into a wider one.
- Reference data and cached lookups: read from the database, with a timeout so slow fallbacks do not pile up.
- Rate limits and lockouts: decide in advance whether to refuse or allow attempts; for sign-in, refusing is the safer default.
- Sessions: users may need to sign in again, but never fall back to unsigned sessions held only in the browser.
- Job queues: producers retry or write to a durable outbox in the database until Redis returns.
What are the common mistakes with Redis in a healthcare app?
The common mistakes with Redis in a healthcare app all come from treating it as harmless temporary storage, when it often holds the same data as the database with fewer controls.
- Caching whole API responses that include patient data in a cache every service can read.
- Writing keys without an expiry and relying on eviction to clean up.
- Leaving the default user with no password and full access because the instance is on the internal network.
- Using patient names or record numbers in key names.
- Forgetting that snapshots and replicas hold the same data as memory.
A worked example: a scheduling service
A clinic scheduling service slows down at peak times because every booking screen loads clinic hours, provider lists and appointment types from the database. Those three are reference data, so they move to Redis with an expiry and are deleted whenever an administrator changes them.
The team also wants to cache each clinic's appointment list for the day. That list contains patient names, so it goes into a separate key space with its own ACL user, a short expiry and deletion on every booking change, and the decision is recorded in the system's data inventory.
Sessions stay in Redis with an expiry that matches the sign-in timeout, and hold only the user id and roles.
What does Redis mean for your build plan?
Redis is quick to add and slow to clean up once many services depend on it, so the data rules should come before the first key is written.
- List what will be cached, classify each item as PHI or not, and agree the expiry for each.
- Decide instances, ACL users and key prefixes before the first cache call is written.
- Agree persistence, encryption and backup settings with whoever owns infrastructure and compliance.
- Add monitoring for memory, evictions, hit rate and keys without an expiry.
How does Agnotic use Redis in healthcare apps?
Agnotic designs what each service may cache, sets up instances, ACL users, TLS and expiry rules, and builds cache invalidation into the code that changes the source data. PHI stays out of shared caches unless there is a documented reason and controls to match.
Fast reads without a second copy of the chart
We set the cache rules, access controls and persistence for each service.
Related reading on Agnotic
Backend design, analytics and engineering practice.


