Class RedisCacheManager.RedisCacheManagerBuilder
java.lang.Object
org.springframework.data.redis.cache.RedisCacheManager.RedisCacheManagerBuilder
- Enclosing class:
- RedisCacheManager
Builder for creating a 
RedisCacheManager.- Since:
- 2.0
- Author:
- Christoph Strobl, Mark Paluch, Kezhu Wang, John Blum
- 
Method SummaryModifier and TypeMethodDescriptionallowCreateOnMissingCache(boolean allowRuntimeCacheCreation) Configure whether to allow cache creation at runtime.build()Create new instance ofRedisCacheManagerwith configuration options applied.Returns the defaultRedisCacheConfiguration.cacheDefaults(RedisCacheConfiguration defaultCacheConfiguration) Define a defaultRedisCacheConfigurationapplied to dynamically createdRedisCaches.cacheWriter(RedisCacheWriter cacheWriter) Configure aRedisCacheWriter.DisableRedisCachecreation at runtime for non-configured, undeclared caches.EnablesRedisCachecreation at runtime for unconfigured, undeclared caches.Enables cache statistics.fromCacheWriter(RedisCacheWriter cacheWriter) Factory method returning a new Builder used to create and configure aRedisCacheManagerusing the givenRedisCacheWriter.fromConnectionFactory(RedisConnectionFactory connectionFactory) Factory method returning a new Builder used to create and configure aRedisCacheManagerusing the givenRedisConnectionFactory.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) Registers the givencache nameandRedisCacheConfigurationused to create and configure aRedisCacheon startup.withInitialCacheConfigurations(Map<String, RedisCacheConfiguration> cacheConfigurations) Append aMapof cache name/RedisCacheConfigurationpairs to be pre initialized.
- 
Method Details- 
fromCacheWriterpublic static RedisCacheManager.RedisCacheManagerBuilder fromCacheWriter(RedisCacheWriter cacheWriter) Factory method returning a new Builder used to create and configure aRedisCacheManagerusing the givenRedisCacheWriter.- Parameters:
- cacheWriter-- RedisCacheWriterused to perform- RedisCacheoperations by executing appropriate Redis commands; must not be null.
- Returns:
- new RedisCacheManager.RedisCacheManagerBuilder.
- Throws:
- IllegalArgumentException- if the given- RedisCacheWriteris null.
- See Also:
 
- 
fromConnectionFactorypublic static RedisCacheManager.RedisCacheManagerBuilder fromConnectionFactory(RedisConnectionFactory connectionFactory) Factory method returning a new Builder used to create and configure aRedisCacheManagerusing the givenRedisConnectionFactory.- Parameters:
- connectionFactory-- RedisConnectionFactoryused by the- RedisCacheManagerto acquire connections to Redis when performing- RedisCacheoperations; must not be null.
- Returns:
- new RedisCacheManager.RedisCacheManagerBuilder.
- Throws:
- IllegalArgumentException- if the given- RedisConnectionFactoryis null.
- See Also:
 
- 
allowCreateOnMissingCachepublic RedisCacheManager.RedisCacheManagerBuilder allowCreateOnMissingCache(boolean allowRuntimeCacheCreation) Configure whether to allow cache creation at runtime.- Parameters:
- allowRuntimeCacheCreation- boolean to allow creation of undeclared caches at runtime; true by default.
- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
 
- 
disableCreateOnMissingCacheDisableRedisCachecreation at runtime for non-configured, undeclared caches.RedisCacheManager.getMissingCache(String)returns null for any non-configured, undeclaredCacheinstead of a newRedisCacheinstance. This allows theCompositeCacheManagerto participate.- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
- Since:
- 2.0.4
- See Also:
 
- 
enableCreateOnMissingCacheEnablesRedisCachecreation at runtime for unconfigured, undeclared caches.- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
- Since:
- 2.0.4
- See Also:
 
- 
cacheDefaultsReturns the defaultRedisCacheConfiguration.- Returns:
- the default RedisCacheConfiguration.
 
- 
cacheDefaultspublic RedisCacheManager.RedisCacheManagerBuilder cacheDefaults(RedisCacheConfiguration defaultCacheConfiguration) Define a defaultRedisCacheConfigurationapplied to dynamically createdRedisCaches.- Parameters:
- defaultCacheConfiguration- must not be null.
- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
 
- 
cacheWriterConfigure aRedisCacheWriter.- Parameters:
- cacheWriter- must not be null.
- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
- Since:
- 2.3
 
- 
enableStatisticsEnables cache statistics.- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
 
- 
initialCacheNamesAppend 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.
 
- 
transactionAwareEnableRedisCaches to synchronize cache put/evict operations with ongoing Spring-managed transactions.- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
 
- 
withCacheConfigurationpublic RedisCacheManager.RedisCacheManagerBuilder withCacheConfiguration(String cacheName, RedisCacheConfiguration cacheConfiguration) Registers the givencache nameandRedisCacheConfigurationused to create and configure aRedisCacheon startup.- Parameters:
- cacheName-- nameof the cache to register for creation on startup.
- cacheConfiguration-- RedisCacheConfigurationused to configure the new cache on startup.
- Returns:
- this RedisCacheManager.RedisCacheManagerBuilder.
- Since:
- 2.2
 
- 
withInitialCacheConfigurationspublic 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.
 
- 
getCacheConfigurationForGet theRedisCacheConfigurationfor a given cache by its name.- Parameters:
- cacheName- must not be null.
- Returns:
- Optional.empty()if no- RedisCacheConfigurationset for the given cache name.
- Since:
- 2.2
 
- 
getConfiguredCachesGet theSetof cache names for which the builder holdsconfiguration.- Returns:
- an unmodifiable Setholding the name of caches for which aconfigurationhas been set.
- Since:
- 2.2
 
- 
buildCreate new instance ofRedisCacheManagerwith configuration options applied.- Returns:
- new instance of RedisCacheManager.
 
 
-