Class JCacheXDistributedCacheManager
- java.lang.Object
-
- io.github.dhruv1110.jcachex.spring.distributed.JCacheXDistributedCacheManager
-
- All Implemented Interfaces:
org.springframework.cache.CacheManager
public class JCacheXDistributedCacheManager extends Object implements org.springframework.cache.CacheManager
Distributed cache manager implementation for JCacheX integration with Spring.This cache manager extends the capabilities of the standard JCacheXCacheManager to provide distributed caching functionality with cluster management, replication, and consistency guarantees.
Key Features:
- Cluster Management: Automatic node discovery and cluster formation
- Replication Control: Configurable replication factors per cache
- Consistency Models: Support for different consistency levels
- Global Operations: Cluster-wide cache operations
- Monitoring: Distributed cache statistics and health monitoring
Usage Examples:
{ @code @Service public class UserService {
- Since:
- 1.0.0
- See Also:
JCacheXCacheManager
,DistributedCache
,JCacheXProperties
-
-
Constructor Summary
Constructors Constructor Description JCacheXDistributedCacheManager(JCacheXProperties properties)
Creates a new distributed cache manager with the specified properties.JCacheXDistributedCacheManager(JCacheXProperties properties, boolean allowNullValues)
Creates a new distributed cache manager with the specified properties and null value handling.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Void>
addNode(String nodeAddress)
Adds a new node to the cluster.org.springframework.cache.Cache
getCache(String name)
Collection<String>
getCacheNames()
io.github.dhruv1110.jcachex.distributed.DistributedCache.ClusterTopology
getClusterTopology()
Gets cluster topology information.io.github.dhruv1110.jcachex.distributed.DistributedCache<Object,Object>
getDistributedCache(String name)
Gets the underlying distributed cache for advanced operations.Map<String,io.github.dhruv1110.jcachex.distributed.DistributedCache.DistributedMetrics>
getDistributedMetrics()
Gets distributed metrics for all caches.void
initializeDistributedCaches()
Creates all distributed caches defined in configuration.CompletableFuture<Void>
invalidateGlobally(String cacheName, Object key)
Performs global invalidation across all nodes for the specified cache and key.CompletableFuture<Void>
rebalanceCluster()
Rebalances data across all nodes in the cluster.CompletableFuture<Void>
removeNode(String nodeId)
Removes a node from the cluster.
-
-
-
Constructor Detail
-
JCacheXDistributedCacheManager
public JCacheXDistributedCacheManager(JCacheXProperties properties)
Creates a new distributed cache manager with the specified properties.- Parameters:
properties
- the JCacheX configuration properties
-
JCacheXDistributedCacheManager
public JCacheXDistributedCacheManager(JCacheXProperties properties, boolean allowNullValues)
Creates a new distributed cache manager with the specified properties and null value handling.- Parameters:
properties
- the JCacheX configuration propertiesallowNullValues
- whether to allow null values in caches
-
-
Method Detail
-
getCache
@Nullable public org.springframework.cache.Cache getCache(String name)
- Specified by:
getCache
in interfaceorg.springframework.cache.CacheManager
-
getCacheNames
public Collection<String> getCacheNames()
- Specified by:
getCacheNames
in interfaceorg.springframework.cache.CacheManager
-
getDistributedCache
@Nullable public io.github.dhruv1110.jcachex.distributed.DistributedCache<Object,Object> getDistributedCache(String name)
Gets the underlying distributed cache for advanced operations.- Parameters:
name
- the cache name- Returns:
- the distributed cache, or null if not found
-
initializeDistributedCaches
public void initializeDistributedCaches()
Creates all distributed caches defined in configuration.
-
getClusterTopology
public io.github.dhruv1110.jcachex.distributed.DistributedCache.ClusterTopology getClusterTopology()
Gets cluster topology information.- Returns:
- cluster topology
-
getDistributedMetrics
public Map<String,io.github.dhruv1110.jcachex.distributed.DistributedCache.DistributedMetrics> getDistributedMetrics()
Gets distributed metrics for all caches.- Returns:
- map of cache names to distributed metrics
-
invalidateGlobally
public CompletableFuture<Void> invalidateGlobally(String cacheName, Object key)
Performs global invalidation across all nodes for the specified cache and key.- Parameters:
cacheName
- the cache namekey
- the key to invalidate- Returns:
- CompletableFuture that completes when invalidation is done
-
rebalanceCluster
public CompletableFuture<Void> rebalanceCluster()
Rebalances data across all nodes in the cluster.- Returns:
- CompletableFuture that completes when rebalancing is done
-
addNode
public CompletableFuture<Void> addNode(String nodeAddress)
Adds a new node to the cluster.- Parameters:
nodeAddress
- the address of the new node- Returns:
- CompletableFuture that completes when the node is added
-
removeNode
public CompletableFuture<Void> removeNode(String nodeId)
Removes a node from the cluster.- Parameters:
nodeId
- the ID of the node to remove- Returns:
- CompletableFuture that completes when the node is removed
-
-