Spring Boot uses CacheManagerCustomizer to customize cache managers. RedisCacheConfiguration calls a list of CacheManagerCustomizers but most of RedisCacheManager methods are private. The only cache configuration access is the method RedisCacheManager#getCacheConfigurations() but it returns an UnmodifiableMap.

Maybe I'm missing something but the only way I found to customize RedisCacheConfiguration TTL per cache is to declared my own RedisCacheManager.

Comment From: snicoll

@jntakpe yes and that's pretty much the case for most cache implementations that do not rely on an external configuration file. If you want to start tuning things per cache, you'd better off adding the 3 lines of code that help you get started with the builder and use that. If we offered that flexibility then we'd be at odds with spring.cache.cache-names as they also allow you to setup caches on startup.

Comment From: jntakpe

@snicoll That not that simple to mix the default Spring cache configuration which works fine for most of our use cases and a tuning per cache. At least it's not "adding 3 lines of code" but more like 3 classes with a lot of copied code from Spring Boot configuration. Anyway, I get your point but I still think allowing access to RedisCacheManager#initialCacheConfiguration or give an equivalent access to the old RedisCacheManager#setExpires(Map) should be considered and would be an improvement

Comment From: snicoll

Fair enough, I guess we can consider opening up things a bit now that RedisCacheManager is immutable.

As for the 3 lines of code, this was literally 3 lines of code. The problem is using your own arrangement and expect Spring Boot configuration properties to kick in: this is something we shouldn't do IMO. Please consider any further configuration optimization to the Spring Data Redis project.

Comment From: jntakpe

Great news ! Thank you for reconsidering

Comment From: snicoll

I've created DATAREDIS-935

Comment From: snicoll

The plan here is to provide a RedisCacheManagerBuilderCustomizer of some sort since RedisCacheManager is immutable.

Comment From: philwebb

Closing in favor of PR #17287

Comment From: uqix

@snicoll RedisCacheManagerBuilderCustomizer usage could be mentioned in reference doc

Comment From: snicoll

@uqix good catch, I've created #19813. In the future, please create a new issue.