[ 
https://issues.apache.org/jira/browse/OAK-12147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rishabh Daim updated OAK-12147:
-------------------------------
    Description: 
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

  was:
Introduce a new Oak-owned cache API in oak-core-spi so that all Oak modules can 
depend on stable interfaces rather than Guava shim or Caffeine types directly.

  New interfaces in org.apache.jackrabbit.oak.cache:

  - OakCache<K,V> — base interface: getIfPresent, get(K, Function) 
(Caffeine-aligned, unchecked, @Nullable), put, invalidate, invalidateAll, 
estimatedSize, asMap, getAllPresent, cleanUp, stats()
  - OakLoadingCache<K,V> extends OakCache — get(K) returns @NotNull, 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()

  No changes to AbstractCacheStats, CacheStats, or CacheLIRS. All existing call 
sites continue to compile unchanged.

  Acceptance criteria:
  - oak-core-spi compiles with no new Caffeine or Guava types in the public API
  - All existing oak-core-spi tests pass
  - No consumer module is changed


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

Reply via email to