You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "rishabhdaim (via GitHub)" <gi...@apache.org> on 2026/03/19 21:28:11 UTC

[PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

rishabhdaim opened a new pull request, #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807

   ## Summary
   
   Migrates all remaining Guava cache API usages to Caffeine (`com.github.benmanes.caffeine`) across the Oak codebase, completing the work started under OAK-11300.
   
   ## Changes
   
   - **oak-core-spi**: `CacheLIRS`, `CacheStats`, `AbstractCacheStats`, `EmpiricalWeigher` — replace Guava `Cache`/`CacheBuilder`/`Weigher`/`CacheStats`; bump `package-info.java` version
   - **oak-store-document**: `DocumentNodeStore`, `DocumentNodeStoreBuilder`, `NodeDocumentCache`, `NodeCache`, `PersistentCache`, `CachingCommitValueResolver`, `LocalDiffCache`, `MemoryDiffCache`, `TieredDiffCache`, `NodeDocument`, `ForwardingListener`, `EvictionListener` — replace Guava cache imports; adapt `Callable` → `Function`, `reload()` → `asyncReload()`
   - **oak-segment-tar**: `SegmentCache`, `ReaderCache`, `RecordCache`, `WriterCacheManager`, `PriorityCache`, `CacheWeights`, `RecordCacheStats`, `SegmentCacheStats` — replace Guava cache imports; add `.executor(Runnable::run)` and `cleanUp()` for synchronous eviction
   - **oak-blob-plugins**: `FileCache`, `CompositeDataStoreCache`, `UploadStagingCache`, `CachingBlobStore`, `AbstractSharedCachingDataStore`, `DataStoreBlobStore` — replace Guava `Cache`/`CacheBuilder`/`CacheLoader`/`AbstractCache`/`Weigher`/`RemovalCause`
   - **oak-blob**: `BlobIdSet` — replace `CacheBuilder` with `Caffeine`
   - **oak-blob-cloud**: `S3Backend` — replace `CacheBuilder` with `Caffeine`
   - **oak-blob-cloud-azure**: `AzureBlobStoreBackend`, `AzureBlobStoreBackendV8` — replace `CacheBuilder` with `Caffeine`
   - **oak-search**: `ExtractedTextCache` — replace Guava `Cache`/`CacheBuilder`/`Weigher` with Caffeine
   - **oak-search-elastic**: `ElasticIndexStatistics` — replace `CacheBuilder`/`CacheLoader`/`LoadingCache`/`Ticker`; `reload()` → `asyncReload()` returning `CompletableFuture`; `getUnchecked()` → `get()`
   - **oak-run-commons**: `DocumentNodeStoreHelper` — replace Guava `Cache` import
   - **oak-benchmarks**: `PersistentCacheTest` — replace Guava `Cache` import
   - **oak-core**: `CacheStatsMetricsTest` — adapt to Caffeine `CacheStats.of()`
   - **pom.xml** (oak-blob, oak-blob-cloud, oak-blob-cloud-azure, oak-search, oak-search-elastic, oak-run-commons, oak-benchmarks) — add Caffeine dependency
   
   ## Test Plan
   
   - [ ] `mvn test -pl oak-core-spi` — CacheLIRS, CacheStats tests
   - [ ] `mvn test -pl oak-store-document` — NodeCache, DocumentNodeStore, persistent cache tests
   - [ ] `mvn test -pl oak-segment-tar` — SegmentCache, PriorityCache tests
   - [ ] `mvn test -pl oak-blob-plugins` — FileCache, CompositeDataStoreCache tests
   - [ ] `mvn test -pl oak-search-elastic` — ElasticIndexStatistics tests
   
   ## Links
   
   - JIRA: https://issues.apache.org/jira/browse/OAK-11946
   - Parent: https://issues.apache.org/jira/browse/OAK-11300


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "jsedding (via GitHub)" <gi...@apache.org>.
jsedding commented on PR #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807#issuecomment-4109264166

   I share the concern of @reschke. Do we really want all our modules (or many of them) to depend on caffeine? Do we know if caffeine follows semantic versioning of its OSGi exports?
   
   Defining an Oak API and implementing it with a (thin) wrapper would compartmentalize this issue to a single module. I would suggest for this wrapper to live in `oak-commons` (or in a separate module). The implementing bundle could just embed caffeine, without exporting it. This would allow us to update or swap out the implementation without any impact on downstream users.


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim closed pull request #2807: OAK-11946 : migrate cache APIs to Caffeine
URL: https://github.com/apache/jackrabbit-oak/pull/2807


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807#issuecomment-4102347238

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2807) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [62.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2807&metric=new_coverage&view=list) (required ≥ 80%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2807)
   
   


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim commented on PR #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807#issuecomment-4093647592

   @reschke how would you suggest to split this ? we are only removing one guava import and rest all the linked to it.


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "jsedding (via GitHub)" <gi...@apache.org>.
jsedding commented on PR #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807#issuecomment-4109511788

   In the past, guava has been problematic, because it needed to be installed alongside the oak bundles in the same OSGi container. Applications built on top of Oak would then start using guava as well.
   
   This caused two points of contention, a bit of a catch 22:
   
   1. the application wanted to use a newer guava version but couldn't update due to Oak and 
   2. we wanted to update the guava version in Oak, but couldn't due to applications depending on the lower guava version.
   
   Matters were made worse in guava's case due to the fact that guava does not follow semantic versioning.
   
   IIUC, the whole exercise of removing guava is done in order to get rid of this sort of problem. Switching caches to caffeine, imported as a dependency in OSGi, does not IMHO solve the problem.
   
   Defining a custom caching API (which could be pretty much a copy of the caffeine API, or whatever) creates a level of decoupling. Embedding the implementation in the bundle implementing this API maximizes the level of decoupling and, for me, is optional, as it could be done at a later time if needed.
   
   BTW, the ticket you linked is closed "Won't do" and concerns itself only with oak-documentstore IIUC.


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on PR #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807#issuecomment-4110291901

   Yup.
   


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-11946 : migrate cache APIs to Caffeine [jackrabbit-oak]

Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim commented on PR #2807:
URL: https://github.com/apache/jackrabbit-oak/pull/2807#issuecomment-4109354033

   > I share the concern of @reschke. Do we really want all our modules (or many of them) to depend on caffeine? Do we know if caffeine follows semantic versioning of its OSGi exports?
   > 
   > Defining an Oak API and implementing it with a (thin) wrapper would compartmentalize this issue to a single module. I would suggest for this wrapper to live in `oak-commons` (or in a separate module). The implementing bundle could just embed caffeine, without exporting it. This would allow us to update or swap out the implementation without any impact on downstream users.
   
   @jsedding We did a discussion on this topic here: https://issues.apache.org/jira/browse/OAK-11791
   
   cc @thomasmueller @reschke 


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org