Reputation: 1089
I have an entity
A and it is defined as @Cacheable
. And I have query cache loading the entity
A under specified cache region say "regionA". This is accomplished by setHint
and enabled cache.
As for the settings in wildfly
, The regionA
is configured with no eviction
and expiration
as 1 day where as the entity
cache has default eviction
and expiration
let say as below.
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="1000000"/>
</local-cache>
<local-cache name="local-query">
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="regionA" statistics-enabled="true">
<eviction strategy="NONE" max-entries="-1"/>
<expiration lifespan="86400000" max-idle="14400000"/>
</local-cache>
Now, if I execute for the 1st time, there are no query cache results, hence SQL is run to fetch the entity. And later the 2nd run, 3rds are seeming to be taken from cache regionA
and hence ok. But after 18hrs, I tried to run the same query and it looks like the query is run again.
But I suppose if the query cache is configured as "1 day" expiration, why does it run SQL
again ? Is it because the entity
cache is expired by that time ? So the entity
cache does not take cache region specific settings ?
How to distinguish these entities stored in the specific cache region follow the region specific settings.
Thanks.
Upvotes: 1
Views: 118
Reputation: 5888
You have max-idle="14400000"
which means that if the query was not executed in the past 4 hours, the cached result expires.
Upvotes: 3