You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Rishabh Daim (Jira)" <ji...@apache.org> on 2026/03/26 12:29:00 UTC
[jira] [Resolved] (OAK-12147) Introduce Oak Cache API interfaces in oak-core-spi
[ https://issues.apache.org/jira/browse/OAK-12147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rishabh Daim resolved OAK-12147.
--------------------------------
Fix Version/s: 2.0.0
Resolution: Fixed
> Introduce Oak Cache API interfaces in oak-core-spi
> --------------------------------------------------
>
> Key: OAK-12147
> URL: https://issues.apache.org/jira/browse/OAK-12147
> Project: Jackrabbit Oak
> Issue Type: Sub-task
> Reporter: Rishabh Daim
> Assignee: Rishabh Daim
> Priority: Critical
> Fix For: 2.0.0
>
>
> Introduce a new Oak-owned cache API in org.apache.jackrabbit.oak.cache so that all Oak modules depend on stable interfaces rather than Guava shim or Caffeine types directly.
> New files:
> - OakCache<K,V> — base interface with:
> - getIfPresent(K) → @Nullable V
> - get(K, Function<? super K, ? extends V>) → @Nullable V (Caffeine-aligned, unchecked — replaces the Callable-based API)
> - put(K, V)
> - invalidate(K)
> - invalidateAll()
> - invalidateAll(Iterable) (no Oak module currently calls this; can be removed if decided)
> - estimatedSize() → long (no Oak module currently calls this directly; can be removed if decided)
> - stats() → OakCacheStats
> - asMap() → ConcurrentMap<K, V>
> - getAllPresent(Iterable) → Map<K, V> (no Oak module currently calls this; CacheLIRS throws UnsupportedOperationException; can be removed if decided)
> - cleanUp() (no Oak module currently calls this; CacheLIRS is a no-op; can be removed if decided)
> - OakLoadingCache<K,V> extends OakCache — get(K) returns @NotNull V, throws CompletionException on loader failure; refresh(K)
> - OakCacheLoader<K,V> — functional interface: V load(K) throws Exception
> - OakWeigher<K,V> — functional interface: int weigh(K, V)
> - OakRemovalCause — enum: EXPLICIT, REPLACED, SIZE, EXPIRED, COLLECTED
> - OakRemovalListener<K,V> — functional interface: void onRemoval(K, V, OakRemovalCause)
> - OakCacheStats — immutable value object: hitCount, missCount, loadSuccessCount, loadFailureCount, totalLoadTime, evictionCount; methods minus(), hitRate(), missRate(), requestCount()
> - CacheImplementation — enum: LIRS, CAFFEINE; used by OakCacheBuilder for per-module backend override
> No changes to AbstractCacheStats, CacheStats, or CacheLIRS. All existing call sites continue to compile unchanged.
> Acceptance criteria:
> - oak-core-spi compiles; no new Caffeine or Guava types in the public API surface
> - All existing oak-core-spi tests pass (CacheTest, CacheSizeTest, ConcurrentTest, ConcurrentPerformanceTest)
> - No consumer module is changed; all existing CacheLIRS.newBuilder() and new CacheStats(guavaCache, ...) call sites still compile
--
This message was sent by Atlassian Jira
(v8.20.10#820010)