Caffeine is the Java 8 successor to ConcurrentLinkedHashMap and Guava's cache. Projects should prefer Caffeine and migrate when requiring JDK8 or higher. The previous caching projects are supported in maintenance mode.
- A linked list runs through a ConcurrentHashMap to provide eviction ordering.
- Avoids lock contention by amortizing the penalty under lock.
- LRU page replacement policy (currently being upgraded to LIRS).
- Equivalent performance to ConcurrentHashMap under load.
- Can bound by the size of the values (e.g. Multimap cache).
- Can notify a listener when an entry is evicted.
See the tutorial for examples of using this library.
- Released v1.4.2 with Least-Recently-Used page replacement policy.
- Integrated into Google Guava (MapMaker, CacheBuilder)
See the Changelog for version history.
v2.x: Implement Low Inter-reference Recency Set page replacement policy.
Caffeine: A Java 8 rewrite of Guava Cache is the current focus for further development.
See the Changelog for more details and current progress.
Maven users should choose one of the dependencies based on their JDK version.
<!-- JDK 6 --> <dependency> <groupId>com.googlecode.concurrentlinkedhashmap</groupId> <artifactId>concurrentlinkedhashmap-lru</artifactId> <version>1.4.2</version> </dependency> <!-- JDK 5 --> <dependency> <groupId>com.googlecode.concurrentlinkedhashmap</groupId> <artifactId>concurrentlinkedhashmap-lru</artifactId> <version>1.2_jdk5</version> </dependency>