Class LoomJCacheManager
java.lang.Object
com.loomcache.server.jcache.LoomJCacheManager
- All Implemented Interfaces:
Closeable, AutoCloseable, javax.cache.CacheManager
JCache-compatible (JSR-107) cache manager.
Implements CacheManager so users can obtain caches through the standard
Caching.getCachingProvider().getCacheManager() flow. Native methods with compatible
signatures are preserved for backwards compatibility.
Manages the lifecycle of cache instances: creation, retrieval, and destruction. Also provides cache enumeration and cleanup.
Thread-safe using ConcurrentHashMap. Once closed, all operations throw IllegalStateException.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new cache manager with the default URI.LoomJCacheManager(URI uri) Create a new cache manager with the specified URI.LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties) Full constructor used byLoomCachingProviderto wire in the owning provider, class loader, and properties per JSR-107 requirements.LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties, @Nullable DataStructureRegistry distributedRegistry) Full constructor including an optionalDataStructureRegistryfor distributed (Raft-replicated) JCache state (P1.4).LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties, @Nullable DataStructureRegistry distributedRegistry, @Nullable com.loomcache.server.jcache.LoomJCacheClusterClient distributedClusterClient) -
Method Summary
Modifier and TypeMethodDescriptionintGet the number of caches managed.voidclose()<K, V, C extends javax.cache.configuration.Configuration<K,V>>
javax.cache.Cache<K, V> createCache(String cacheName, C configuration) <K,V> LoomJCache <K, V> createCache(String name, LoomJCacheConfig<K, V> config) Create a cache with the given name and LoomCache-native configuration.voiddestroyCache(String name) Destroy (remove and close) a cache by name.voidenableManagement(String cacheName, boolean enabled) voidenableStatistics(String cacheName, boolean enabled) <K,V> @Nullable LoomJCache <K, V> Native get-by-name returning our raw cache type (backwards compatible).<K,V> @Nullable javax.cache.Cache <K, V> javax.cache.spi.CachingProvidergetURI()booleanisClosed()booleanisOpen()Check if the manager is open.<T> T
-
Constructor Details
-
LoomJCacheManager
public LoomJCacheManager()Create a new cache manager with the default URI. -
LoomJCacheManager
Create a new cache manager with the specified URI.- Parameters:
uri- the URI identifying this cache manager (must not be null)
-
LoomJCacheManager
public LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties) Full constructor used byLoomCachingProviderto wire in the owning provider, class loader, and properties per JSR-107 requirements. -
LoomJCacheManager
public LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties, @Nullable DataStructureRegistry distributedRegistry) Full constructor including an optionalDataStructureRegistryfor distributed (Raft-replicated) JCache state (P1.4).When
distributedRegistryis non-null, any cache created through this manager defaults to distributed mode so its state is Raft-replicated together with the rest of the node's data structures. -
LoomJCacheManager
public LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties, @Nullable DataStructureRegistry distributedRegistry, @Nullable com.loomcache.server.jcache.LoomJCacheClusterClient distributedClusterClient)
-
-
Method Details
-
createCache
Create a cache with the given name and LoomCache-native configuration.- Type Parameters:
K- the key typeV- the value type- Parameters:
name- the cache name (not null)config- the LoomCache-native configuration (not null)- Returns:
- the created cache
- Throws:
IllegalStateException- if manager is closedjavax.cache.CacheException- if cache already exists
-
getCache
Native get-by-name returning our raw cache type (backwards compatible).- Specified by:
getCachein interfacejavax.cache.CacheManager
-
destroyCache
Destroy (remove and close) a cache by name.- Specified by:
destroyCachein interfacejavax.cache.CacheManager
-
getCachingProvider
public javax.cache.spi.CachingProvider getCachingProvider()- Specified by:
getCachingProviderin interfacejavax.cache.CacheManager
-
getURI
- Specified by:
getURIin interfacejavax.cache.CacheManager
-
getClassLoader
- Specified by:
getClassLoaderin interfacejavax.cache.CacheManager
-
getProperties
- Specified by:
getPropertiesin interfacejavax.cache.CacheManager
-
createCache
public <K, V, C extends javax.cache.configuration.Configuration<K,V>> javax.cache.Cache<K,V> createCache(String cacheName, C configuration) throws IllegalArgumentException - Specified by:
createCachein interfacejavax.cache.CacheManager- Throws:
IllegalArgumentException
-
getCache
-
getCacheNames
-
cacheCount
public int cacheCount()Get the number of caches managed. -
enableManagement
- Specified by:
enableManagementin interfacejavax.cache.CacheManager
-
enableStatistics
- Specified by:
enableStatisticsin interfacejavax.cache.CacheManager
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfacejavax.cache.CacheManager
-
unwrap
- Specified by:
unwrapin interfacejavax.cache.CacheManager
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejavax.cache.CacheManager- Specified by:
closein interfaceCloseable
-
isOpen
public boolean isOpen()Check if the manager is open.
-