-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
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")
Metadata
Metadata
Assignees
Labels
No labels