ahanikel commented on code in PR #1155:
URL: https://github.com/apache/jackrabbit-oak/pull/1155#discussion_r1380152396


##########
oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CachingDataStoreTest.java:
##########
@@ -638,4 +643,34 @@ private void waitFinish() {
             e.printStackTrace();
         }
     }
+
+    @Test
+    public void testRecordCacheInGetRecordIfStored() throws Exception {
+        // we have to initialise the datastore with the recordCache enabled
+        tear();
+
+        final File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
+        final String id = getIdForInputStream(f);
+        final DataIdentifier di = new DataIdentifier(id);
+
+        init(1, 64 * 1024 * 1024, 10, 10000L);
+        // we write directly to the backend because that's the situation we 
have in a shared remote datastore:
+        // the file was already written by a different datastore but isn't 
present in the datastore.cache.
+        backend.write(di, f);
+
+        assertTrue("The datastore was initialised with a recordCacheSize of 
10000 but the recordCache is not present",
+                dataStore.recordCache.isPresent());
+        assertNull("Record with id " + id + " should not be in the recordCache 
yet",
+                dataStore.recordCache.get().getIfPresent(id));
+        assertNotNull("The record could not be loaded from the backend",
+                dataStore.getRecordIfStored(di));
+        assertNotNull("Record with id " + id + " should be in the recordCache 
now",
+                dataStore.recordCache.get().getIfPresent(id));
+        // make sure the record is loaded from the cache
+        backend.deleteRecord(di);

Review Comment:
   @amit-jain The thing is that I'm deleting the record from the cache in 
AbstractSharedCachingDataStore#deleteRecord as well: 
https://github.com/ahanikel/jackrabbit-oak/blob/issues/OAK-10494/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java#L331
 so the following assert would fail.
   The reason I'm deleting from the backend here is just to prove that the 
record is actually read from the cache.



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