@Test public void testSanity() { AtomicInteger count = new AtomicInteger(0); ThreadLocalCache<String, String> cache = new ThreadLocalCache<>(2, key -> { return key + count.getAndAdd(1); }); assertEquals(cache.get("abc"), "abc0"); assertEquals(cache.get("abc"), "abc0"); assertEquals(cache.get("def"), "def1"); assertEquals(cache.get("abc"), "abc0"); assertEquals(cache.get("ghi"), "ghi2"); assertEquals(cache.get("abc"), "abc3"); }
public V get(K key) { V value = cache.get().computeIfAbsent(key, loader); return requireNonNull(value, "loader returned null value"); }
ThreadLocalCache { public V get(K key) { V value = cache.get().computeIfAbsent(key, loader); return requireNonNull(value, "loader returned null value"); } }
ThreadLocalCache { public V get(K key) { V value = cache.get().computeIfAbsent(key, loader); return requireNonNull(value, "loader returned null value"); } ThreadLocalCache(int maxSizePerThread, Function<K, V> loader); }
ThreadLocalCache { public V get(K key) { V value = cache.get().computeIfAbsent(key, loader); return requireNonNull(value, "loader returned null value"); } ThreadLocalCache(int maxSizePerThread, Function<K, V> loader); V get(K key); }
ThreadLocalCache { public V get(K key) { V value = cache.get().computeIfAbsent(key, loader); return requireNonNull(value, "loader returned null value"); } ThreadLocalCache(int maxSizePerThread, Function<K, V> loader); V get(K key);  }