santro
santro

Reputation: 393

cache update when using Hibernate query cache

I am using hibernate query cache mechanism to store query results in cache memory and will be retrieved from cache.But if any update in the table, it should be updated in the cache when next query hits the table. Here i am using same query like select * from table. when i tried this,i am getting same information even table is upted.

Upvotes: 0

Views: 133

Answers (1)

Andy Dufresne
Andy Dufresne

Reputation: 6190

If the objects are not updated through hibernate, hibernate would not know about them and hence the query cache is not updated. If you are updated through hibernate but on a different application server then you need to use a distributed cache that spans across a cluster. for e.g. JBoss Tree Cache.

If you can't control the updates from happening externally but you know the time/period when the occur you could keep the TTL of this query cache shorter than that so that hibernate evicts the entries from the cache before they are updated from outside.

Upvotes: 1

Related Questions