Set TTL fot caching different data with one CacheManager in Spring Boot
I used multiple cache managers combined with cache resolver. I followed these tutorials.
https://www.baeldung.com/spring-multiple-cache-managers
https://www.baeldung.com/spring-boot-caffeine-cache
how to configure different ttl for each redis cache when using @cacheable in springboot2.0
If you need configure different expire time for cache when using @cacheable ,
you can configure different CacheManager with different ttl,and specify cacheManager when using cache in your service.
@Cacheable(cacheManager = "expireOneHour", value = "onehour", key = "'_onehour_'+#key", sync = true)
How to set TTL on Hazelcast cache map with spring cacheble
There are two topologies in which you can use Hazelcast: Embedded and Client-Server. Your Java Spring configuration configures Hazelcast Client, however your hazelcast.yaml
is dedicated for the Embedded mode.
Try to either use your hazelcast.yaml
configuration in your Hazelcast server. Or configure your cache in the Hazelcast client, for example, like this:
@Bean
HazelcastInstance hazelcastInstance() {
HazelcastInstance instance = HazelcastClient.newHazelcastClient(clientConfig());
instance.getConfig().addMapConfig(new MapConfig("items").setTimeToLiveSeconds(120));
return instance;
}
Related Topics
How to Handle Errors in Spring-Webflux
How to Autowire a Component Which Is Having Constructor With Arguments in Springboot Application
Refactor Multiple If' Statements in Java-8
How to Change Cookie Processor to Legacycookieprocessor in Tomcat 8
How to Set the Radio Button Based on the Value Fetched from the Database
How to Clean Project Cache in Intellij Idea Like Eclipse'S Clean
How to Return a List of Specific Type Instead of List<Object[]> in Hibernate
How to Find the Number of Times If or Else Code Has Executed
How to Get Image Height and Width Using Java
Getting Versioncode and Versionname from Google Play
Spring-Data-Jpa Repository - Underscore on Entity Column Name
Multiple Queries Executed in Java in Single Statement
Optimizing Multiple If-Else Condition in Java
How to Get Amount of Tens in a Int