Interface ICache<K,V>

Type Parameters:
K - the cache key type
V - the cache value type
All Superinterfaces:
AutoCloseable, javax.cache.Cache<K,V>, Closeable, Iterable<javax.cache.Cache.Entry<K,V>>
All Known Implementing Classes:
LoomJCache

public interface ICache<K,V> extends javax.cache.Cache<K,V>
LoomCache JCache extension interface.

Extends the portable JSR-107 Cache contract with operations that are useful for cache implementations but not present in the standard API.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface javax.cache.Cache

    javax.cache.Cache.Entry<K,V>
  • Method Summary

    Modifier and Type
    Method
    Description
    CompletableFuture<@Nullable V>
    getAsync(K key)
    Asynchronously retrieve a cache entry.
    putAsync(K key, V value)
    Asynchronously store a cache entry.
    boolean
    setExpiryPolicy(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
    Associate a live cache entry with a key-specific expiry policy.

    Methods inherited from interface javax.cache.Cache

    clear, close, containsKey, deregisterCacheEntryListener, get, getAll, getAndPut, getAndRemove, getAndReplace, getCacheManager, getConfiguration, getName, invoke, invokeAll, isClosed, iterator, loadAll, put, putAll, putIfAbsent, registerCacheEntryListener, remove, remove, removeAll, removeAll, replace, replace, unwrap

    Methods inherited from interface Iterable

    forEach, spliterator
  • Method Details

    • setExpiryPolicy

      boolean setExpiryPolicy(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
      Associate a live cache entry with a key-specific expiry policy.

      The supplied policy takes precedence over the cache-wide expiry policy for this key. The entry's time-to-live is recalculated immediately from ExpiryPolicy.getExpiryForUpdate(). If the key is absent or already expired, no policy is stored and the method returns false.

      Parameters:
      key - the existing cache key
      expiryPolicy - the key-specific expiry policy
      Returns:
      true if a live entry was updated, false otherwise
    • getAsync

      CompletableFuture<@Nullable V> getAsync(K key)
      Asynchronously retrieve a cache entry.
      Parameters:
      key - the cache key
      Returns:
      a future completed with the value, or null if absent
    • putAsync

      CompletableFuture<Void> putAsync(K key, V value)
      Asynchronously store a cache entry.
      Parameters:
      key - the cache key
      value - the cache value
      Returns:
      a future completed when the write finishes