The other day I needed to cache some data that should expire. Thanks to Google Collections this was incredibly easy.

The entries in this map will expire in 1 hour. Super easy and pretty clean too. Thanks Google.

ConcurrentMap<String, String> cache = new MapMaker().expiration(1, TimeUnit.HOURS).makeMap();