python – How to reset TTL when a redis key is accessed?

By Groupda Whatsapp Group Link

Updated On:

Follow Us

 

I have some keys with TTL in redis. So, normally the key will be evicted when the TTL passed.

But what I want to do is, in every access (retrieval) to the key, I will want to reset the TTL to the original value I set earlier.

For example: I have set 2 hours for a key. After 1 hour later, the key is accessed. I want to set the TTL to 2 hours again at that time. So, the key will only be evicted if it’s not accessed in its TTL lifetime.

Join Now:  python - How to reset TTL when a redis key is accessed?

How to do this efficiently?

Source link

Leave a Comment

+ Add Whatsapp
+ Telegram