I don't want to rely upon the default TTL of 1 hour provided by hibernate so I am configuring custom TTL for my hibernate query cache region.
My application is using hibernate on DAO level and we are using hazelcast in client server mode as second level cache provider for hibernate.
This is how I am using the hibernate query cache - refer below code snippet
Criteria criteria = getSession().createCriteria(MyClass.java);
criteria.setCacheable(true);
criteria.setCacheRegion("my.query.cache.region");
criteria.list();
Below is the hibernate configuration -
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
Below is the map config for "my.query.cache.region" in hazelcast.xml residing on hazelcast server
<map name="default">
<time-to-live-seconds>180</time-to-live-seconds>
</map>
After doing all this I am checking the stats of the "my.query.cache.region"
getSession().getSessionFactory().getStatistics().getSecondLevelCacheStatistics("my.query.cache.region")
I am observing that 180 seconds ~ 3 mins of TTL is not having any impact, the cache is expiring after an hour only - means picking the default hibernate TTL of 1 hour.
Please guide me where i am going wrong. how can i configure the TTL for hibernate query cache regions?