jsedding commented on code in PR #68:
URL: 
https://github.com/apache/sling-org-apache-sling-servlets-resolver/pull/68#discussion_r3572219781


##########
src/main/java/org/apache/sling/servlets/resolver/internal/resolution/ResolutionCache.java:
##########
@@ -278,17 +293,33 @@ public Servlet get(final AbstractResourceCollector 
context) {
         return null;
     }
 
-    public void put(final AbstractResourceCollector context, final Servlet 
candidate) {
-        final Map<AbstractResourceCollector, Servlet> localCache = 
this.cache.get();
-        if (localCache != null) {
-            if (localCache.size() < this.cacheSize) {
-                localCache.put(context, candidate);
-            } else if (this.logCacheSizeWarning) {
-                this.logCacheSizeWarning = false;
-                logger.warn(
-                        "Script cache has reached its limit of {}. You might 
want to increase the cache size for the servlet resolver.",
-                        this.cacheSize);
+    /**
+     * @return the current cache generation, to be passed to {@link #put(long, 
AbstractResourceCollector, Servlet)}
+     */
+    public long getGeneration() {
+        return this.generation.get();
+    }
+
+    /**
+     * Caches the candidate unless the cache has been flushed since {@code 
generation} was obtained,
+     * i.e. the resolution that produced the candidate may be based on stale 
data.
+     */
+    public void put(final long generation, final AbstractResourceCollector 
context, final Servlet candidate) {

Review Comment:
   The javadoc for `Map#computeIfAbsent` states
   
   > If the function returns null no mapping is recorded.
   
   Anyway, this change is fine as-is 🙂



-- 
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]

Reply via email to