Reputation: 334
Is there a implementation of java.util.Map that automatically expires its entries when not accessed for specified amount of time. I found many libraries that auto expires entry with some time limits. But I have extra condition. Entry should be removed only when it is not accessed for the time duration.
Upvotes: 0
Views: 709
Reputation: 1209
You can use Guava's cache.
It has two options:
What you want is number 2.
Upvotes: 3
Reputation: 776
If you want something that gets evicted after a specified amount of time, I would suggest Guavas Cache https://github.com/google/guava/wiki/CachesExplained#timed-eviction
If the entry isn't queried during the time specified, it gets auto-evicted.
Upvotes: 2