import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
public class Example {
public static void main(String[] args) {
ConcurrentLinkedHashMap<String, String> cache = new ConcurrentLinkedHashMap.Builder<String, String>()
.maximumWeightedCapacity(100)
.build();
cache.put("key1", "value1");
cache.put("key2", "value2");
cache.put("key3", "value3");
String value1 = cache.get("key1");
System.out.println(value1);
boolean containsKey = cache.containsKey("key2");
System.out.println(containsKey);
String removedValue = cache.remove("key3");
System.out.println(removedValue);
}
}
<dependency>
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
<artifactId>concurrentlinkedhashmap-lru</artifactId>
<version>1.4.2</version>
</dependency>