<dependency> <groupId>com.googlecode.concurrentlinkedhashmap</groupId> <artifactId>concurrentlinkedhashmap-lru</artifactId> <version>1.4</version> </dependency> import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; ConcurrentLinkedHashMap<String, String> cache = new ConcurrentLinkedHashMap.Builder<String, String>() .maximumWeightedCapacity(1000) .build(); String key = "example_key"; String value = cache.get(key); if(value == null) { value = fetchDataFromDatabase(key); cache.put(key, value); } ConcurrentLinkedHashMap<String, String> cache = new ConcurrentLinkedHashMap.Builder<String, String>() .maximumWeightedCapacity(1000) .concurrencyLevel(32) .build();


上一篇:
下一篇:
切换中文