risdenk commented on code in PR #1118:
URL: https://github.com/apache/solr/pull/1118#discussion_r1003541142


##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -275,7 +275,7 @@ public V computeIfAbsent(K key, IOFunction<? super K, ? 
extends V> mappingFuncti
   @Override
   public V put(K key, V val) {
     inserts.increment();
-    V old = cache.asMap().put(key, val);
+    V old = cache.asMap().compute(key, (k, v) -> val);

Review Comment:
   does this need to use `.asMap()`? can we just use `cache.get(key, 
mapping_function)`? This looks to be the same concept w/o trying to access the 
underlying map.
   
   
https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/3.1.1/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Cache.html#get(K,java.util.function.Function)
   
   if using `asMap()` -` compute` looks correct based on 
https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/3.1.1/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Cache.html#asMap(),
 but it looks like we don't even need `asMap()`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to