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?