Redis Keyspace configuration not working as expected #3109
Labels
status: waiting-for-feedback
We need additional information before we can continue
status: waiting-for-triage
An issue we've not yet triaged
I am trying to set up a Redis repository with programmatic keyspaces configuration according to https://docs.spring.io/spring-data/redis/reference/redis/redis-repositories/keyspaces.html
I would like to load the
timeToLive
from a configuration properties.Problem
Here is the attempt:
As opposed to the documentation, the
KeyspaceSettings
are not static, so we have to pass or access the configuration somehow.timeToLivePropertyName = "my.config.redis-ttl-seconds"
field inKeyspaceSettings
, but it did not have any effect.MyConfigurationProperties
in theKeyspaceConfig
constructor (and using@EnableRedisRepositories(keyspaceConfiguration = KeyspaceConfig::class)
) , but that doesn't workkeyValueMappingContext()
bean, but it doesn't work as expected, see belowRunning the application results in the following output:
This shows that
KeyspaceConfig
is instantiated from elsewhere, and that instance is used to callinitialConfiguration()
on, instead of the one that is constructed inkeyValueMappingContext()
, which I would expect.Workaround
If not declaring a separate
KeyspaceConfig
class, but instead implement aKeyspaceConfiguration
on-the-fly, it works:Output:
Issues
KeyspaceConfig
when one needs to load properties dynamically or from configuration properties?The text was updated successfully, but these errors were encountered: