ConcurrentLinkedHashMap<Integer, String> cache = new ConcurrentLinkedHashMap.Builder<Integer, String>() .maximumWeightedCapacity(1000) .build(); cache.put(1, "Hello"); cache.put(2, "World"); String value = cache.get(1);