© Anton Dolganin 2025
Everyone knows about EXPIRE
for keys.
But Redis can also remove elements from a ZSET
, SET
, or LIST
using TTL-like logic — by storing them with a timestamp as the score and cleaning them up manually.
You don’t need cron for this. Just:
ZADD my:queue 1715366400 "job:123"
Then periodically:
ZREMRANGEBYSCORE my:queue -inf <current_time>
No real TTL. Just time that’s passed.
© Anton Dolganin 2025