When Redis keys seem to disappear randomly, the cause is often not corruption. It is usually eviction doing exactly what the configured memory policy told Redis to do. The confusion comes from the fact that missing keys, expired keys, overwritten keys, and rejected writes can all look similar from the application side.
The short version: confirm whether Redis is actually under maxmemory pressure, confirm which eviction policy is active, and only then decide whether disappearing keys are caused by eviction, expiration, or application behavior.
What eviction means in Redis
Redis applies eviction only when memory pressure interacts with a configured maxmemory limit.
That means disappearing keys under pressure are often expected behavior, not mysterious behavior. Your first checks should be:
- is
maxmemoryconfigured? - what is
maxmemory-policy? - are you actually under pressure right now?
If the answer to the last question is no, missing keys are more likely explained by expiration, overwrite, deletion, or application logic.
Why keys disappear differently under different policies
Redis supports policies such as:
noevictionallkeys-lruallkeys-lfuallkeys-randomvolatile-lruvolatile-lfuvolatile-randomvolatile-ttl
The critical difference is whether Redis can evict from all keys or only from keys that already have TTL.
If a team assumes “only cache keys should disappear” but the policy is allkeys-*, Redis may be behaving correctly while the incident still feels surprising.
Eviction, expiration, and overwrite are not the same thing
Teams often group these together, but the debugging path changes depending on which one is really happening.
- eviction: Redis removes keys because of memory pressure plus policy
- expiration: keys disappear because TTL reached zero
- overwrite or delete: the application changed or removed the key
If keys are not expiring when they should, the next guide is Redis Keys Not Expiring.
If writes are failing instead of keys disappearing, compare the same incident with Redis OOM Command Not Allowed.
Check whether the real problem is missing TTL
Eviction issues and TTL issues often appear together.
A common pattern looks like this:
- the app expects cache keys to expire
- some keys lose TTL after overwrite
- memory rises
- eviction begins affecting keys in a way the team did not expect
In that case, policy is only part of the story. TTL behavior is the earlier branch.
Common policy misunderstandings
1. Assuming volatile-* affects all keys
It does not. Those policies consider only keys with TTL.
2. Assuming noeviction means nothing bad happens
It means Redis avoids eviction and can fail writes that need additional memory instead.
3. Assuming eviction explains every missing key
Sometimes the application overwrote, deleted, or expired the key instead.
4. Forgetting that workload shape changes the outcome
The same policy can feel very different under bursty writes, large values, or bad TTL hygiene.
A practical debugging order
- inspect current memory usage
- inspect
maxmemory - inspect
maxmemory-policy - confirm whether the missing keys had TTL
- inspect whether writes are also failing
- decide whether the current policy matches the data importance model
This sequence is usually safer than changing policy immediately during an incident.
Quick commands to ground the investigation
redis-cli CONFIG GET maxmemory
redis-cli CONFIG GET maxmemory-policy
redis-cli INFO memory
redis-cli INFO stats
Use these commands to confirm whether Redis is allowed to evict keys, whether pressure is real, and whether evicted-key counters are rising during the incident.
A simple decision shortcut
Use this fast branch when keys seem to disappear:
- memory pressure is high and
evicted_keysrises: think eviction first - TTL is counting down as expected: think expiration first
- memory pressure is low and TTL is missing: think overwrite or delete first
- writes fail with OOM errors: think
noevictionor exhausted memory first
That shortcut will not replace a full incident review, but it often prevents teams from blaming the wrong subsystem for the first 30 minutes.
Symptom shortcuts
- Start here if keys disappear unexpectedly under memory pressure.
- If keys are not expiring at all, the TTL guide is usually the better first stop.
- If writes are failing with OOM errors, the OOM guide is usually the more direct entry.
FAQ
Q. Why are only some keys disappearing?
Because the active policy may target only volatile keys or may prefer certain access patterns such as LRU or LFU.
Q. Does noeviction protect writes?
No. It avoids eviction and can cause writes that need more memory to fail instead.
Q. What should I inspect first?
Check maxmemory, maxmemory-policy, and whether the missing keys had TTL.
Q. When is policy not the main problem?
When memory pressure is weak or absent, or when the real issue is expiration or application overwrite behavior.
Read Next
- If the missing keys are really an expiration problem, continue with Redis Keys Not Expiring.
- If writes fail instead of keys disappearing, continue with Redis OOM Command Not Allowed.
- If memory pressure itself is the bigger problem, continue with Redis Memory Usage High.
Related Posts
Sources:
- https://redis.io/docs/latest/develop/reference/eviction/
- https://redis.io/docs/latest/commands/info/
While AdSense review is pending, related guides are shown instead of ads.
Start Here
Continue with the core guides that pull steady search traffic.
- Middleware Troubleshooting Guide: Redis vs RabbitMQ vs Kafka A practical middleware troubleshooting guide for developers covering when to reach for Redis, RabbitMQ, or Kafka symptoms first, and which problem patterns usually belong to each tool.
- Kubernetes CrashLoopBackOff: What to Check First A practical Kubernetes CrashLoopBackOff troubleshooting guide covering startup failures, probe issues, config mistakes, and what to inspect first.
- Kafka Consumer Lag Increasing: Troubleshooting Guide A practical Kafka consumer lag troubleshooting guide covering what lag usually means, which consumer metrics to check first, and how poll timing, processing speed, and fetch patterns affect lag.
- Kafka Rebalancing Too Often: Common Causes and Fixes A practical Kafka troubleshooting guide covering why consumer groups rebalance too often, what poll timing and group protocol settings matter, and how to stop rebalances from interrupting useful work.
- Docker Container Keeps Restarting: What to Check First A practical Docker restart-loop troubleshooting guide covering exit codes, command failures, environment mistakes, health checks, and what to inspect first.
While AdSense review is pending, related guides are shown instead of ads.