Can I delete keys with expiration times set in Redis using Node.js?

Question

Grade: Education Subject: Support
Can I delete keys with expiration times set in Redis using Node.js?
Asked by:
67 Viewed 67 Answers

Answer (67)

Best Answer
(410)
No, `redis.del()` only deletes the key itself. It does *not* remove the associated expiry information. If you want to remove keys with expiration times, you need to use `redis.ex()` or `redis.setex()` to set the expiration time and then delete the key using `redis.del()` after the expiry time has passed. Alternatively, you can use `redis.keys('*')` to get all keys and then filter based on expiration times.