Class RedisCacheManager.RedisCacheManagerBuilder
java.lang.Object
org.springframework.data.redis.cache.RedisCacheManager.RedisCacheManagerBuilder
- Enclosing class:
- RedisCacheManager
Configurator for creating
RedisCacheManager.- Since:
- 2.0
- Author:
- Christoph Strobl, Mark Paluch, Kezhu Wang
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Create new instance ofRedisCacheManagerwith configuration options applied.cacheDefaults(RedisCacheConfiguration defaultCacheConfiguration) Define a defaultRedisCacheConfigurationapplied to dynamically createdRedisCaches.cacheWriter(RedisCacheWriter cacheWriter) Configure aRedisCacheWriter.Disable in-flightCachecreation for unconfigured caches.fromCacheWriter(RedisCacheWriter cacheWriter) Entry point for builder styleRedisCacheManagerconfiguration.fromConnectionFactory(RedisConnectionFactory connectionFactory) Entry point for builder styleRedisCacheManagerconfiguration.getCacheConfigurationFor(String cacheName) Get theRedisCacheConfigurationfor a given cache by its name.Get theSetof cache names for which the builder holdsconfiguration.initialCacheNames(Set<String> cacheNames) Append aSetof cache names to be pre initialized with currentRedisCacheConfiguration.EnableRedisCaches to synchronize cache put/evict operations with ongoing Spring-managed transactions.withCacheConfiguration(String cacheName, RedisCacheConfiguration cacheConfiguration) withInitialCacheConfigurations(Map<String, RedisCacheConfiguration> cacheConfigurations) Append aMapof cache name/RedisCacheConfigurationpairs to be pre initialized.
-
Method Details
-
fromConnectionFactory
public static RedisCacheManager.RedisCacheManagerBuilder fromConnectionFactory(RedisConnectionFactory connectionFactory) Entry point for builder styleRedisCacheManagerconfiguration.- Parameters:
connectionFactory- must not be null.- Returns:
- new
RedisCacheManager.RedisCacheManagerBuilder.
-
fromCacheWriter
public static RedisCacheManager.RedisCacheManagerBuilder fromCacheWriter(RedisCacheWriter cacheWriter) Entry point for builder styleRedisCacheManagerconfiguration.- Parameters:
cacheWriter- must not be null.- Returns:
- new
RedisCacheManager.RedisCacheManagerBuilder.
-
cacheDefaults
public RedisCacheManager.RedisCacheManagerBuilder cacheDefaults(RedisCacheConfiguration defaultCacheConfiguration) Define a defaultRedisCacheConfigurationapplied to dynamically createdRedisCaches.- Parameters:
defaultCacheConfiguration- must not be null.- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder.
-
cacheWriter
Configure aRedisCacheWriter.- Parameters:
cacheWriter- must not be null.- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder. - Since:
- 2.3
-
transactionAware
EnableRedisCaches to synchronize cache put/evict operations with ongoing Spring-managed transactions.- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder.
-
initialCacheNames
Append aSetof cache names to be pre initialized with currentRedisCacheConfiguration. NOTE: This calls depends oncacheDefaults(RedisCacheConfiguration)using whatever defaultRedisCacheConfigurationis present at the time of invoking this method.- Parameters:
cacheNames- must not be null.- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder.
-
withInitialCacheConfigurations
public RedisCacheManager.RedisCacheManagerBuilder withInitialCacheConfigurations(Map<String, RedisCacheConfiguration> cacheConfigurations) Append aMapof cache name/RedisCacheConfigurationpairs to be pre initialized.- Parameters:
cacheConfigurations- must not be null.- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder.
-
withCacheConfiguration
public RedisCacheManager.RedisCacheManagerBuilder withCacheConfiguration(String cacheName, RedisCacheConfiguration cacheConfiguration) - Parameters:
cacheName-cacheConfiguration-- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder. - Since:
- 2.2
-
disableCreateOnMissingCache
Disable in-flightCachecreation for unconfigured caches.RedisCacheManager.getMissingCache(String)returns null for any unconfiguredCacheinstead of a newRedisCacheinstance. This allows eg.CompositeCacheManagerto chime in.- Returns:
- this
RedisCacheManager.RedisCacheManagerBuilder. - Since:
- 2.0.4
-
getConfiguredCaches
Get theSetof cache names for which the builder holdsconfiguration.- Returns:
- an unmodifiable
Setholding the name of caches for which aconfigurationhas been set. - Since:
- 2.2
-
getCacheConfigurationFor
Get theRedisCacheConfigurationfor a given cache by its name.- Parameters:
cacheName- must not be null.- Returns:
Optional.empty()if noRedisCacheConfigurationset for the given cache name.- Since:
- 2.2
-
enableStatistics
- Returns:
- Since:
- 2.4
-
build
Create new instance ofRedisCacheManagerwith configuration options applied.- Returns:
- new instance of
RedisCacheManager.
-