ExpiringCache { public final synchronized void putValue(@Nullable V value) { this.value = new SoftReference<>(value); expiresAt = calcExpiresAt(); } 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 testPutValue() { String value1 = subject.getValue(); subject.putValue("test"); String value2 = subject.getValue(); assertEquals("test", value2); assertNotEquals(value1, value2); }