https://github.com/ben-manes/concurrentlinkedhashmap
A ConcurrentLinkedHashMap for Java
https://github.com/ben-manes/concurrentlinkedhashmap
Last synced: 9 months ago
JSON representation
A ConcurrentLinkedHashMap for Java
- Host: GitHub
- URL: https://github.com/ben-manes/concurrentlinkedhashmap
- Owner: ben-manes
- License: apache-2.0
- Created: 2015-03-12T19:19:32.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-10-01T19:03:55.000Z (over 5 years ago)
- Last Synced: 2024-10-18T11:24:43.073Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 53.2 MB
- Stars: 471
- Watchers: 31
- Forks: 113
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - ConcurrentLinkedHashMap
README
[Caffeine](https://github.com/ben-manes/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 high performance version of [java.util.LinkedHashMap](http://java.sun.com/javase/6/docs/api/java/util/LinkedHashMap.html) for use as a
software cache. The project was migrated from its [old website](https://code.google.com/p/concurrentlinkedhashmap/) on Google Code.
# Design #
* A linked list runs through a [ConcurrentHashMap](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html) to
provide eviction ordering.
* Avoids lock contention by amortizing the penalty under lock.
See the [design document](https://github.com/ben-manes/concurrentlinkedhashmap/wiki/Design) and the StrangeLoop conference
[slides](http://concurrentlinkedhashmap.googlecode.com/files/ConcurrentCachingAtGoogle.pdf) ([Concurrent Caching at
Google](https://thestrangeloop.com/sessions/concurrent-caching-with-mapmaker)).
# Features #
* LRU page replacement policy (currently being upgraded to LIRS).
* Equivalent performance to [ConcurrentHashMap](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html) 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](https://github.com/ben-manes/concurrentlinkedhashmap/wiki/ExampleUsage) for examples of using this library.
# Status #
* **Released v1.4.2** with _Least-Recently-Used_ page replacement policy.
* Integrated into [Google Guava](http://code.google.com/p/guava-libraries/)
([MapMaker](http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/MapMaker.html),
[CacheBuilder](http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/cache/CacheBuilder.html))
See the [Changelog](https://github.com/ben-manes/concurrentlinkedhashmap/wiki/Changelog) for version history.
## Future ##
* v2.x: Implement [Low Inter-reference Recency Set](http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/abs02-6.html) page replacement
policy.
* [Caffeine](https://github.com/ben-manes/caffeine): A Java 8 rewrite of Guava Cache is the current focus for further development.
See the [Changelog](https://github.com/ben-manes/concurrentlinkedhashmap/wiki/Changelog) for more details and current progress.
## Maven ##
Maven users should choose one of the dependencies based on their JDK version.
```
com.googlecode.concurrentlinkedhashmap
concurrentlinkedhashmap-lru
1.4.2
com.googlecode.concurrentlinkedhashmap
concurrentlinkedhashmap-lru
1.2_jdk5
```
# Performance #
In this benchmark an unbounded [ConcurrentHashMap](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html) is
compared to a
[ConcurrentLinkedHashMap](http://concurrentlinkedhashmap.googlecode.com/svn/wiki/release-1.3.1-LRU/com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap.html)
v1.0 with a maximum size of 5,000 entries under an artificially high load (250 threads, 4-cores).

