amit-jain commented on code in PR #1155:
URL: https://github.com/apache/jackrabbit-oak/pull/1155#discussion_r1381603087
##########
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:
What I meant was if you call `AbstractSharedCachingDataStore#deleteRecord.`
then invalidate is called implicitly and the test then also covers that change.
--
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]