I use
@Value("${cache.host}")
private String redisHost;
@Value("${cache.port}")
private int redisPort;
I want to get timeToLive in @RedishHash from application properties. How can get this config?
@RedisHash(value = "UserModel", timeToLive = 5)
I give manually above however I want to give from application.properties
2
Answers
i’m not sure if you can do that from application.properties, but u can do it by configuring a RedisCacheManager bean with java based configuration like below :
PS : this method should be in a class with @Configuration annotation
You can create a
@Component
where you are going to take the values from propertiesThen you need to reference as