I build CacheDeck, an iPhone app for checking production Redis during an incident. You won't need it here: everything below runs in Docker with redis-cli.
A cache key had a 600-second TTL until one write:
> SET k v1 EX 600 OK > TTL k (integer) 600 > SET k v2 OK > TTL k (integer) -1 -1 means the key has no expiry. Per the SET docs, "any previous time to live associated with the key is discarded on successful SET operation." If your refresh path calls a plain SET, each refreshed key stays in memory until you delete it or an allkeys-* policy evicts it.
My setup: the redis:8 image (Redis 8.10.3) in Docker on a Mac mini M4, 24 November 2026.
Writes that drop the TTL, and writes that keep it
I gave each key a 600-second TTL. After one command I read TTL again:
| Command | TTL after |
|---|---|
SET k v2 | -1 |
SET k v2 XX | -1 |
SET k v2 GET | -1 |
GETSET k v2 | -1 |
MSET k v2 z v3 | -1 |
LPOP of the last element, then RPUSH L b | -1 |
HDEL of the last field, then HSET H f2 2 | -1 |
SET k v2 KEEPTTL | 600 |
SET k v2 EX 900 | 900 |
APPEND, SETRANGE, INCR, INCRBYFLOAT | 600 |
RPUSH, HSET, SADD on a non-empty key | 600 |
RENAME k k2, COPY k k2 | 600 on k2 |
The SET family replaces the whole key, expiry included. Commands that change the value in place keep the TTL, and KEEPTTL (Redis 6.0+) makes SET keep it too. If you use a list as a queue, watch the two collection rows: when a list or hash loses its last element, Redis deletes the key, and the next push creates a new key without a TTL.
Counting the keys without a TTL
INFO keyspace gives the exact count. I wrote 90,000 cache:product:* keys with EX 3600 and 10,000 cache:user:* keys with a plain SET:
db0:keys=100000,expires=90000,avg_ttl=3598041,subexpiry=0 keys minus expires is 10,000, the number of keys with no TTL. avg_ttl stays the same with or without them: after a minute, 1,000 keys with 300 permanent ones among them read avg_ttl=544916, and 1,000 keys with none read avg_ttl=544965. My reading: Redis computes it from keys that have a TTL. On the first read after a bulk write it showed 0, and a second later 599,864.
To find the family that lost its TTL, I asked for the TTL of every scanned key and grouped the permanent ones by prefix:
redis-cli --scan --count 1000 > keys.txt sed 's/^/TTL /' keys.txt | redis-cli > ttls.txt paste ttls.txt keys.txt | awk '$1 == -1 {print $2}' | cut -d: -f1-2 | sort | uniq -c It printed 10000 cache:user after 7.1 seconds for 100,000 keys, on loopback inside the container. Key names with spaces or newlines break this pipeline. Each TTL is a separate round trip, so on a busy primary run it against a replica.
volatile-lru can only evict keys that have a TTL
Open-source Redis ships with maxmemory-policy noeviction. AWS ElastiCache, Google Memorystore and Azure Cache for Redis default to volatile-lru, which evicts only keys with a TTL. The eviction docs add that the volatile-* policies behave like noeviction once no key has a TTL.
I wrote 300,000 values of 400 bytes into a server with maxmemory 64mb. A fixed share of the writes went out without a TTL, the rest with EX 3600:
| Policy | Writes without TTL | Failed writes (OOM) | Keys at the end | Of them with a TTL | Evicted |
|---|---|---|---|---|---|
noeviction | 0% | 172,676 | 127,324 | 127,324 | 0 |
volatile-lru | 0% | 0 | 125,280 | 125,280 | 174,768 |
volatile-lru | 30% | 0 | 129,004 | 39,004 | 171,046 |
volatile-lru | 60% | 81,097 | 131,515 | 0 | 87,388 |
volatile-lru | 100% | 166,955 | 133,045 | 0 | 0 |
allkeys-lru | 30% | 0 | 127,000 | 88,903 | 173,049 |
Two more runs of the 30% and 60% rows came within 2,000 keys and 2,000 errors of these numbers.
At 30%, all 90,000 keys without a TTL stayed in memory, and 39,004 keys with a TTL fit next to them. At 60%, Redis evicted every key that had a TTL and refused the rest of the writes:
OOM command not allowed when used memory > 'maxmemory'. evicted_keys stops growing at that point. INFO errorstats counts the refusals: errorstat_OOM:count=80777 on a repeat run. With noeviction, a TTL on every key didn't help, because none of them had expired yet. allkeys-lru evicts both kinds, and the mix stayed at 70/30.
Reading the numbers
| You see | It means | Check next |
|---|---|---|
keys larger than expires in INFO keyspace | that many keys have no TTL | group them by prefix with SCAN and TTL |
avg_ttl looks normal | keys without a TTL don't move it | use keys − expires |
avg_ttl=0 in the first second after a restart or bulk load | Redis hasn't computed it yet | read it again a second later |
expires falling toward 0 under volatile-lru while evicted_keys grows | eviction is running out of candidates | find the keys without a TTL before writes fail |
errorstat_OOM growing | Redis refuses writes at maxmemory | free memory or change the policy |
A queue key with TTL -1 | it emptied, and a push recreated it | EXPIRE q 600 NX after each push; it sets a TTL only when the key has none (Redis 7.0+) |
CacheDeck's free key browser shows the TTL of each key (guide), and the Workbench runs INFO keyspace in the free tier. In Pro, Analyze charts memory by TTL from a sample of up to 2,000 keys, and the incident deep scan reports "Many keys have no expiry" when more than half of a sample of up to 5,000 keys has none. The finding states that it comes from a sample. Setting a TTL from the app is a write and needs Pro. cachedeck.com
Earlier in this series: mem_fragmentation_ratio read 17.94 on an empty server, and SCAN returned 1,973 empty pages.
Tell me in the comments how far apart keys and expires are on your largest instance.
Redis is a registered trademark of Redis Ltd. CacheDeck is not affiliated with, endorsed by, or sponsored by Redis Ltd.


