Reputation: 1078
I want to make the key live longer if some condition met.
What I think is if I can query all the keys close to expire (like 10 minutes to expire), then I can do the query-check-activate intervally. I seached but not found any clue, if you know how to achieve it, please tell me. Any help will be highly appreciated!
Upvotes: 3
Views: 4112
Reputation: 49962
Querying for keys based on their expiration time is not supported by Redis at the moment.
You can work around this by not using Redis' built-in expiration and managing it yourself, e.g. by using a Sorted Set to track expiration times and implementing passive and active expiration in your application.
Alternatively, you can use SCAN
to crawl the keyspace, fetching TTLs and performing your evaluations.
Upvotes: 3