Class LoomJCache<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
ICache<K,V>, Closeable, AutoCloseable, Iterable<javax.cache.Cache.Entry<K, V>>, javax.cache.Cache<K, V>
Implements Cache so the cache can be used through the standard JSR-107
API. Legacy native methods (e.g. invoke(Object, EntryProcessor),
registerCacheEntryListener(CacheEntryListener)) are preserved and live alongside their
JSR-107 counterparts via overloading.
Supports standard cache operations: get, put, remove, containsKey, getAll, putAll, removeAll, getAndPut, getAndRemove, getAndReplace, putIfAbsent, replace, and invoke.
Supports cache entry listeners for CREATED, UPDATED, REMOVED, and EXPIRED events. Configuration is immutable and supplied at creation time.
TCK compliance: the default CI gate runs the official JSR-107 TCK
harness from the jcache-tck Maven profile across provider, cache, loader/writer,
entry processor, expiry, listener, management, and annotation contracts.
-
Nested Class Summary
Nested classes/interfaces inherited from interface javax.cache.Cache
javax.cache.Cache.Entry<K,V> -
Constructor Summary
ConstructorsConstructorDescriptionLoomJCache(LoomJCacheConfig<K, V> config) Create a new JCache instance with default manager URI.LoomJCache(LoomJCacheConfig<K, V> config, String managerUri) Create a new JCache instance.LoomJCache(LoomJCacheConfig<K, V> config, String managerUri, @Nullable com.loomcache.server.jcache.LoomJCacheClusterClient distributedClusterClient) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclose()booleancontainsKey(K key) voidderegisterCacheEntryListener(CacheEntryListener<K, V> listener) Deregister a native cache entry listener.voidderegisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cfg) JSR-107: deregister a listener by its configuration.@Nullable V@Nullable V@Nullable VgetAndRemove(K key) @Nullable VgetAndReplace(K key, V value) CompletableFuture<@Nullable V> Asynchronously retrieve a cache entry.@Nullable javax.cache.CacheManagerNative accessor for the configuration (typed).getConfiguration(Class<C> clazz) JSR-107 typed configuration accessor.getName()@Nullable CacheStatisticsManagerGet the statistics manager for this cache, if statistics are enabled.<T> @Nullable Tinvoke(K key, EntryProcessor<K, V, T> processor) Invoke a native entry processor on the entry for the specified key.<T> @Nullable TJSR-107 entry-processor invocation.invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K, V, T> processor, Object... args) JSR-107 bulk entry-processor invocation.booleaniterator()voidloadAll(Set<? extends K> keys, boolean replaceExistingValues, @Nullable javax.cache.integration.CompletionListener completionListener) voidvoidAsynchronously store a cache entry.booleanputIfAbsent(K key, V value) voidregisterCacheEntryListener(CacheEntryListener<K, V> listener) Register a native cache entry listener.voidregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cfg) JSR-107: register a listener via its configuration.booleanRemove a key from the cache.booleanRemove a key only if it maps to the specified value.voidJSR-107Cache.removeAll(): remove every entry, firing REMOVED per entry (differs fromclear()which suppresses listener events).voidbooleanbooleanbooleansetExpiryPolicy(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy) Associate a live cache entry with a key-specific expiry policy.intsize()Get the number of entries in the cache.<T> TMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.cache.Cache
isClosedMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
LoomJCache
Create a new JCache instance with default manager URI.- Parameters:
config- the cache configuration
-
LoomJCache
Create a new JCache instance.- Parameters:
config- the cache configurationmanagerUri- the URI of the owning cache manager (for MXBean ObjectName)
-
LoomJCache
public LoomJCache(LoomJCacheConfig<K, V> config, String managerUri, @Nullable com.loomcache.server.jcache.LoomJCacheClusterClient distributedClusterClient)
-
-
Method Details
-
isDistributed
public boolean isDistributed()- Returns:
- whether this cache is running in distributed (Raft-replicated) mode.
-
get
-
put
-
remove
-
remove
-
containsKey
-
setExpiryPolicy
Description copied from interface:ICacheAssociate 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 returnsfalse.- Specified by:
setExpiryPolicyin interfaceICache<K,V> - Parameters:
key- the existing cache keyexpiryPolicy- the key-specific expiry policy- Returns:
trueif a live entry was updated,falseotherwise
-
getAsync
-
putAsync
-
getAll
-
putAll
-
removeAll
-
removeAll
-
clear
-
getAndPut
-
getAndRemove
-
getAndReplace
-
putIfAbsent
-
replace
-
replace
-
invoke
Invoke a native entry processor on the entry for the specified key. -
invoke
-
invokeAll
-
loadAll
-
registerCacheEntryListener
Register a native cache entry listener. -
deregisterCacheEntryListener
Deregister a native cache entry listener. -
registerCacheEntryListener
-
deregisterCacheEntryListener
-
iterator
-
getConfiguration
Native accessor for the configuration (typed). -
getConfiguration
-
getName
-
getCacheManager
-
size
public int size()Get the number of entries in the cache.Not part of JSR-107 Cache API — provided for convenience.
-
getStatisticsManager
Get the statistics manager for this cache, if statistics are enabled. -
close
-
unwrap
-