rishabhdaim commented on code in PR #3176:
URL: https://github.com/apache/jackrabbit-oak/pull/3176#discussion_r4184218537


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/CacheMetadata.java:
##########
@@ -128,30 +137,48 @@ void clear() {
         metadataMap.clear();
     }
 
-    private MetadataEntry getOrCreate(K key, boolean readFromPersistentCache) {
+    private MetadataEntry getOrCreate(K key, V value, boolean 
readFromPersistentCache) {
         if (!enabled) {
             return null;
         }
-        MetadataEntry metadata = metadataMap.get(key);
-        if (metadata == null) {
-            MetadataEntry newEntry = new 
MetadataEntry(readFromPersistentCache);
-            MetadataEntry oldEntry = metadataMap.putIfAbsent(key, newEntry);
-            metadata = oldEntry == null ? newEntry : oldEntry;
-        }
-        return metadata;
+        MetadataEntry existing = metadataMap.get(key);
+        if (existing != null && existing.isFor(value)) {
+            return existing;
+        }
+        if (existing == null) {
+            MetadataEntry created = new MetadataEntry(value, 
readFromPersistentCache);
+            existing = metadataMap.putIfAbsent(key, created);
+            if (existing == null) {
+                return created;
+            }
+            if (existing.isFor(value)) {

Review Comment:
   No, concurrent request can put different values.



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