I am new to Hazelcast. I am trying to implement caching in my spring boot application. I have created a config class for hazlecast with two map configs(CacheObject and CacheList). I have two methods objectMethod() which returns a single employee Object and listMethod() which returns list of employee Objects.
I am using @cacheable annotation on objectMethod and listMethod. The problem is only the object cache is working the list cache is not working. When I run the program in debug mode the object cache is returns value without going into the method but list cache always executes the methods and gets the value from the database.
Am I missing any configuration or anything else?
I am using Spring boot version 2.1.3.RELEASE, Hazelcast version 3.11.1 and Hazelcast-spring version 3.11.1.
I tried spring actuator cache url to see the cache but I am only seeing CacheObject not CacheList.
http://localhost:8080/actuator/caches
{"cacheManagers":{"cacheManager":{"caches":{"CacheObject":{"target":"com.hazelcast.map.impl.proxy.MapProxyImpl"}}}}}
config class
@Configuration
public class HazelcastCacheConfig {
@Bean
public Config cacheConfig() {
return new Config().setInstanceName("hazelcast-instance")
.addMapConfig(new MapConfig().setName("CacheObject")
.setMaxSizeConfig(new MaxSizeConfig(100, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_SIZE))
.setEvictionPolicy(EvictionPolicy.LRU).setTimeToLiveSeconds(86400))
.addMapConfig(new MapConfig().setName("CacheList")
.setMaxSizeConfig(new MaxSizeConfig(100, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_SIZE))
.setEvictionPolicy(EvictionPolicy.LRU).setTimeToLiveSeconds(86400));
}
@cacheable annotation
@Cacheable(value="CacheList")
public List<Employee> getEmployeeList(String a, String b, String b){
//Query
return employeeList;
}
@Cacheable(value="CacheObject")
public Employee getEmployeeObject(String a, String b, String v) {
//Query
return employeeObject;
}
Employee class
public class Employee implements Serializable{
private static final long serialVersionUID = 1L;
private string a,
private string b,
private string c,
private UUID d,
private Map<String,String> e;
}