ExpiringCacheMap { public @Nullable V putIfAbsentAndGet(K key, Supplier<V> action) { return putIfAbsentAndGet(key, new ExpiringCache<>(expiry, action)); } ExpiringCacheMap(Duration expiry);  ExpiringCacheMap(long expiry); void put(K key, Supplier<@Nullable V> action); void put(K key, ExpiringCache<@Nullable V> item); void putIfAbsent(K key, ExpiringCache<V> item); @Nullable V putIfAbsentAndGet(K key, Supplier<V> action); @Nullable V putIfAbsentAndGet(K key, ExpiringCache<V> item); @SuppressWarnings({ "null", "unused" }) void putValue(K key, @Nullable V value); boolean containsKey(K key); void remove(K key); void clear(); synchronized Set<K> keys(); @SuppressWarnings({ "null", "unused" }) @Nullable V get(K key); synchronized Collection<@Nullable V> values(); @SuppressWarnings({ "null", "unused" }) synchronized void invalidate(K key); synchronized void invalidateAll(); @SuppressWarnings({ "null", "unused" }) synchronized @Nullable V refresh(K key); synchronized Collection<@Nullable V> refreshAll();  }
@Test public void testPutIfAbsentAndGet() { String response = subject.putIfAbsentAndGet(FIRST_TEST_KEY, PREDICTABLE_CACHE_ACTION_1); assertEquals(RESPONSE_1, response); assertEquals(RESPONSE_1, subject.get(FIRST_TEST_KEY)); response = subject.putIfAbsentAndGet(FIRST_TEST_KEY, PREDICTABLE_CACHE_ACTION_2); assertEquals(RESPONSE_1, response); assertNotEquals(RESPONSE_2, response); }