I have some keys which have expiration in redis. I check them with EXISTS in my application and I decide based on its output.
When they reach their expiration time, the TTL command, returns -1, but they are not removed from redis and EXISTS command still returns 1 for them; which my app assumes that they are not yet expired.
However, since I realized that these keys will be deleted once someone tries to access them using SCAN or similar commands, I tried to do the same. I used SCAN on my key, but it didn't delete my key.
Is there any command to check if a key is not expired? A command that returns 1 only if both following conditions are true:
- The key exists in redis
- The expiration of the is positive