Class JCacheXDistributedCacheFactory
- java.lang.Object
-
- io.github.dhruv1110.jcachex.spring.distributed.JCacheXDistributedCacheFactory
-
public class JCacheXDistributedCacheFactory extends Object
Factory for creating distributed caches with Spring configuration integration.This factory allows programmatic creation of distributed caches while respecting the global configuration defaults defined in JCacheXProperties. It provides seamless scaling from local to distributed caching.
Key Features:
- Configuration Integration: Respects global distributed properties
- Cluster Management: Automatic cluster formation and node discovery
- Consistency Control: Configurable consistency levels per cache
- Replication Management: Configurable replication factors
- Spring Compatible: Works seamlessly with Spring's dependency injection
Usage Examples:
{ @code @Service public class CacheService {
- Since:
- 1.0.0
- See Also:
JCacheXProperties
,JCacheXDistributedCacheManager
,DistributedCache
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
JCacheXDistributedCacheFactory.DistributedCacheConfigurator<K,V>
Functional interface for configuring distributed cache builders.
-
Constructor Summary
Constructors Constructor Description JCacheXDistributedCacheFactory(JCacheXProperties properties)
Creates a new distributed cache factory with the specified properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V>createDistributedCache(String cacheName)
Creates a distributed cache with the specified name using default configuration.<K,V>
io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V>createDistributedCache(String cacheName, JCacheXDistributedCacheFactory.DistributedCacheConfigurator<K,V> configurator)
Creates a distributed cache with the specified name and custom configuration.<K,V>
io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V>createDistributedCache(String cacheName, Class<K> keyType, Class<V> valueType, JCacheXDistributedCacheFactory.DistributedCacheConfigurator<K,V> configurator)
Creates a distributed cache with the specified name, types, and custom configuration.Set<String>
getCacheNames()
Gets all registered distributed cache names.<K,V>
io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V>getDistributedCache(String cacheName)
Gets an existing distributed cache by name.boolean
hasDistributedCache(String cacheName)
Checks if a distributed cache with the specified name exists.<K,V>
io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V>removeDistributedCache(String cacheName)
Removes a distributed cache from the registry.
-
-
-
Constructor Detail
-
JCacheXDistributedCacheFactory
public JCacheXDistributedCacheFactory(JCacheXProperties properties)
Creates a new distributed cache factory with the specified properties.- Parameters:
properties
- the JCacheX configuration properties
-
-
Method Detail
-
createDistributedCache
public <K,V> io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V> createDistributedCache(String cacheName)
Creates a distributed cache with the specified name using default configuration.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
cacheName
- the name of the cache- Returns:
- the created distributed cache instance
-
createDistributedCache
public <K,V> io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V> createDistributedCache(String cacheName, JCacheXDistributedCacheFactory.DistributedCacheConfigurator<K,V> configurator)
Creates a distributed cache with the specified name and custom configuration.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
cacheName
- the name of the cacheconfigurator
- function to customize the cache configuration- Returns:
- the created distributed cache instance
-
createDistributedCache
public <K,V> io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V> createDistributedCache(String cacheName, Class<K> keyType, Class<V> valueType, JCacheXDistributedCacheFactory.DistributedCacheConfigurator<K,V> configurator)
Creates a distributed cache with the specified name, types, and custom configuration.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
cacheName
- the name of the cachekeyType
- the key type classvalueType
- the value type classconfigurator
- function to customize the cache configuration- Returns:
- the created distributed cache instance
-
getDistributedCache
public <K,V> io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V> getDistributedCache(String cacheName)
Gets an existing distributed cache by name.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
cacheName
- the name of the cache- Returns:
- the cache instance, or null if not found
-
hasDistributedCache
public boolean hasDistributedCache(String cacheName)
Checks if a distributed cache with the specified name exists.- Parameters:
cacheName
- the cache name- Returns:
- true if the cache exists
-
removeDistributedCache
public <K,V> io.github.dhruv1110.jcachex.distributed.DistributedCache<K,V> removeDistributedCache(String cacheName)
Removes a distributed cache from the registry.- Parameters:
cacheName
- the cache name- Returns:
- the removed cache, or null if not found
-
-