I have a query cache called RatesCache to store the result of my database call of RateEntities.
I set the query cache like this for test purpose and every 30s ttl, when it expires it make a new call to database:
<cache alias="RatesCache">
<expiry>
<ttl unit="seconds">30</ttl>
</expiry>
<resources>
<heap unit="entries">1000000</heap>
</resources>
<jsr107:mbeans enable-management="true" enable-statistics="true"/>
</cache>
My rateEntity cache has a longer ttl like 12000 seconds.
My problem is whenever my query cache expires, the new result set is get BUT not stored in rateEntity cache.
The old values are still there. So when I update the database (outside of hibernate), i get the updated value when its from database each 30s but the nexts calls retrieve me the old value (the one in the entity cache) that should be replaced.
How to fix this situation, i.e clear and set the cache entity with the new result set when the ttl expires and i do the query from the database.
Thanks a lot, if you can help I'm struggling a lot since few weeks :)
PS: I tried also to make the entity cache expires before but it does n+1 call issues to database.