-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Second level cache objects getting invalidated
PostPosted: Wed May 26, 2004 7:36 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
I'm using the EHCache as a second level cache, which is working fine when I store an object, re-loading it several times in different sessions (i.e. multiple requests) uses the cache and avoids the database hit. Which is great.

However, if I update the object, it forces the cache to be invalidated and reloads the complete object graph from the database. I wouldn't expect this behaviour as hibernate should know what has changed, and so should need to invalidate the second level cache object.

Am I missing something, is is possible to ensure that objects in second level are not evicted on update (i.e. I want to stop the object being re-loaded from the database as hibernate will know what has changed and could just update the second level cahce with the changes, rather than just invalidating.

Many thanks, Pete.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 9:04 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
evicting an object from the cache when it's updated is the way a cache should work

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 9:29 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
Seems strange to me.... I'm sure it should evict - but should it not update the object in the cache, rather than force it to re-read from the database. I've noticed that it behaves differently depending on whether you use "read-write" - I was using "nonstrict-read-write".

My object are being found in the cache (so some progress) although it hasn't stopped it also hitting the database. If anyone can help I'd be grateful for some advice, otherwise I'll carryon stepping through hibernate code.

Pete.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 9:32 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
i think you're forgetting concurrence hell....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 11:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, anthony is correct.

In certain circumstances (when it is safe, depending upon concurrency strategy, and the type of "thing" being cached), Hibernate does directly update the cache.

But remember that Hibernate is MUCH more fussy about transaction isolation than the typical cache you would build in your application!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.