OAK-12147 : introduce Oak cache API interfaces#2814
Merged
rishabhdaim merged 3 commits intotrunkfrom Mar 26, 2026
Merged
Conversation
…ache, OakCacheStats etc.)
|
reschke
approved these changes
Mar 26, 2026
Contributor
reschke
left a comment
There was a problem hiding this comment.
LGTM. If there's something wrong we'll find out later.
| * A size-bounded, thread-safe cache. | ||
| * | ||
| * <p>Implementations may use different eviction strategies (LIRS, W-TinyLFU/Caffeine, | ||
| * etc.) but callers see only this interface. Obtain instances via OakCacheBuilder.</p> |
Contributor
There was a problem hiding this comment.
Suggested change
| * etc.) but callers see only this interface. Obtain instances via OakCacheBuilder.</p> | |
| * etc.) but callers see only this interface. Obtain instances via OakCacheBuilder. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Introduces the Oak-owned cache API in
oak-core-spi(org.apache.jackrabbit.oak.cache), decoupling callers from CacheLIRS and Guava implementation details. This is TASK-1 of the Caffeine migration (OAK-11300).Changes
OakCache<K,V>— size-bounded thread-safe cache interface (@ProviderType)OakLoadingCache<K,V>— extendsOakCache, adds auto-loadingget(K)andrefresh(K)(@ProviderType)OakCacheLoader<K,V>—@FunctionalInterfaceloader supplied toOakCacheBuilder.build()OakWeigher<K,V>—@FunctionalInterfaceweigher for weight-based evictionOakRemovalListener<K,V>—@FunctionalInterfaceeviction/invalidation callbackOakRemovalCause— enum (EXPLICIT,REPLACED,SIZE,EXPIRED,COLLECTED)OakCacheStats— immutable value object with hit/miss/load/eviction counters andminus()delta supportpackage-info.java— bumped@Versionfrom2.0to2.1(OSGi minor bump for new public types)OakCacheStatsTest— 9 JUnit 4 tests covering all methods and edge casesNo production call sites are changed in this task.
OakCacheBuilder(TASK-2) will wire these interfaces to CacheLIRS and Caffeine adapters.Test Plan
OakCacheStatsTest— 9 tests, all passingmvn test -pl oak-core-spi— BUILD SUCCESSLinks