0

I want to implement a dictionary with keys having a TTL (Time to live). I have tried the Passive Removal of the keys approach, where the keys whose TTL have expired are removed on access (by set and get function). (same as this approach: https://pypi.org/project/expiringdict/)

Can we implement the functionality (in Python) of removing the expired keys in a periodic manner, where we use a thread that runs periodically (say every 5 seconds) to remove the expired keys?

  • Try this https://pypi.org/project/expiringdict/ – MubtadaNaqvi Feb 17 '21 at 06:37
  • @MubtadaNaqvi Thank you for the reference. I really appreciate it. I have read the approach discussed in the link you mentioned. I want to know if we can implement the periodic expiration of keys using threads in Python? – Kartik Aneja Feb 17 '21 at 06:42
  • Does this answer your question? [Time expiry dictionary in memory in Python](https://stackoverflow.com/questions/53244035/time-expiry-dictionary-in-memory-in-python) – DennisLi Mar 30 '22 at 15:29
  • Hi! Did you find a solution for this problem? – Furin Apr 04 '22 at 21:30

0 Answers0