You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spring boot auto configures RedisConnectionFactory if spring-data-redis exists on classpath and RedisConnectionFactory is initialized in LettuceConnectionConfiguration if Lettuce-core available on classpath.
I've only one Redis store as of now, so leveraging Spring boot auto configuration.
Now I'm adding two redis stores, one redis store used as default and other is used when specified with parameter cacheManager = "secondayCacheManager" in @Cacheable annotation so, application should've capability to cache/cache-get on both redis stores.
To configure both Redis Stores, we've to configure both the primary and secondary RedisConnectionFactory and cacheManager using custom configuration. (because spring doesn't auto configure RedisConnectionFactory if it already exists in any custom configuration)
Now the above is custom configuration and missing lot of logic that is happening while configuring RedisConnectionFactory in LettuceConnectionConfiguration.
Auto configure logic for LettuceConnectionConfiguration is package private so, cannot be called directly from custom configuration.
We would like to leverage the auto configure logic in LettuceConnectionConfiguration while configuring the custom RedisConnectionFactory for both primary and secondary redis caches.
Is there a way to achieve this?
Reason being we would like keep the redis connection configurations as it is done by spring boot auto configure.
Currently using below code to configure both the primary and secondary RedisConnectionFactory with Pool configuration and some code copy pasted from LettuceConnectionConfiguration class.
LettuceConnectionConfiguration is specific to Spring Boot. Generally speaking, once you add multiple data sources, all downstream configuration requires explicit wiring.
Spring boot auto configures
RedisConnectionFactory
ifspring-data-redis
exists on classpath andRedisConnectionFactory
is initialized inLettuceConnectionConfiguration
if Lettuce-core available on classpath.I've only one Redis store as of now, so leveraging Spring boot auto configuration.
Now I'm adding two redis stores, one redis store used as default and other is used when specified with parameter
cacheManager = "secondayCacheManager"
in@Cacheable
annotation so, application should've capability to cache/cache-get on both redis stores.To configure both Redis Stores, we've to configure both the primary and secondary
RedisConnectionFactory
andcacheManager
using custom configuration. (because spring doesn't auto configureRedisConnectionFactory
if it already exists in any custom configuration)Now the above is custom configuration and missing lot of logic that is happening while configuring
RedisConnectionFactory
inLettuceConnectionConfiguration
.Auto configure logic for
LettuceConnectionConfiguration
is package private so, cannot be called directly from custom configuration.Reason being we would like keep the redis connection configurations as it is done by spring boot auto configure.
Currently using below code to configure both the primary and secondary
RedisConnectionFactory
with Pool configuration and some code copy pasted fromLettuceConnectionConfiguration
class.I've asked the question here as well:
https://stackoverflow.com/questions/75432050/leverage-spring-boot-redis-auto-configure-logic-for-redisconnectionfactory
The text was updated successfully, but these errors were encountered: