ExpiringCache { public synchronized @Nullable V getValue() { V cachedValue = value.get(); if (cachedValue == null || isExpired()) { return refreshValue(); } return cachedValue; } ExpiringCache(Duration expiry, Supplier<@Nullable V> action);  ExpiringCache(long expiry, Supplier<@Nullable V> action); synchronized @Nullable V getValue(); final synchronized void putValue(@Nullable V value); final synchronized void invalidateValue(); synchronized @Nullable V refreshValue(); boolean isExpired();  }
@Test public void testGetValue() { String value1 = subject.getValue(); assertNotNull(value1); String value2 = subject.getValue(); assertNotNull(value2); assertEquals(value1, value2); }