Card with automatically expiring items

I need a Map (or any set) that supports timeouts for records and automatically deletes them.

I know that guava MapMaker MapMaker , but it finishes its elements on subsequent read / write operations, and not automatically, using a stream. In addition, MapMaker expiration MapMaker now moving to CacheBuilder . The thing is, I donโ€™t want a cache - I need expiring elements

Is there anything ready to use? (itโ€™s not difficult to implement it yourself, but itโ€™s better to use something)

+7
source share
4 answers

Could be: http://code.google.com/p/concurrentlinkedhashmap/wiki/ExpirableCache
More likely not ... he has a lot of unresolved imports.

+2
source

If nothing else, you can provide a dummy CacheLoader that just throws exceptions and just doesn't call Cache.get - it only interacts with the asMap . This is ugly, but we are working to better support this case in 11.0. Make sure you have Guava 10.0.1 if you try this.

And yes, Cache.cleanUp is there for you to call as often as you want, from what you want.

+2
source

Apache Mina ExpiringMap is exactly what you are looking for.

http://mina.apache.org/mina-project/apidocs/org/apache/mina/util/ExpiringMap.html

0
source

I would recommend using Map , which is provided by Hazelcast. It also provides distributed capabilities, but perhaps you are not interested. You just need to configure the expiration policy ( time-to-live-seconds and max-idle-seconds ) and use Map as if it were a Java HashMap .

More information can be found here: Hazelcast Distributed Card

0
source

All Articles