About the use of CacheWriter after it has been removed #686
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @WeiMingzhi, Cache<String, Integer> cache = Caffeine.newBuilder().build();
cache.asMap().compute("a", (key, oldValue) -> {
int newValue = 1;
System.out.printf("%s: %d => %d%n", key, oldValue, newValue);
return newValue;
});
cache.asMap().compute("a", (key, oldValue) -> {
int newValue = 2;
System.out.printf("%s: %d => %d%n", key, oldValue, newValue);
return newValue;
});
System.out.printf("Cache contains: %s%n", cache.asMap());
cache.asMap().compute("a", (key, oldValue) -> {
System.out.printf("%s: %d => %d%n", key, oldValue, null);
return null;
});
System.out.printf("Cache contains: %s%n", cache.asMap()); a: null => 1
a: 1 => 2
Cache contains: {a=2}
a: 2 => null
Cache contains: {} I hope that helps clarify things. Please let me know if you have further questions. |
Beta Was this translation helpful? Give feedback.
Hi @WeiMingzhi,