You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the cache in its ConcurrentMap form (.asMap()), when time-limited entries expire the .get() method returns null as is should, but the .putIfAbsent() method return the old-expired value.
Consider the following example:
Cache<Integer, String> cache1 = Caffeine.newBuilder()
.expireAfterWrite(1, TimeUnit.SECONDS)
.build();
ConcurrentMap<Integer, String> cache2 = cache1.asMap();
cache2.put(1, "A");
Thread.sleep(2000);
System.out.println(cache2.get(1)); // Expect to see null (and see null)
System.out.println(cache2.putIfAbsent(1, "B")); // Expect to see null (and see "A")
The text was updated successfully, but these errors were encountered:
Using the cache in its ConcurrentMap form (.asMap()), when time-limited entries expire the .get() method returns null as is should, but the .putIfAbsent() method return the old-expired value.
Consider the following example:
The text was updated successfully, but these errors were encountered: