-->
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.  [ 3 posts ] 
Author Message
 Post subject: Evict cache on exception
PostPosted: Fri Sep 16, 2005 6:39 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Hi all,

I have a cache issue with Hibernate 3.0.5. I've configured a read-write cache on an object that it's externally modified. I know that's a bad idea, 'cause it may produce ObjectNotFoundException if the object is loaded but deleted from db.
What I want to do is to tune the cache usage without disabling it (the table is accessed about 3 times a sec, so it's really important).
The table is updated every hour by a batch process. I think I can manually evict cache for the table when processing ends, but it's still not sure.
I wonder if there's a way to make Hibernate retry the query on a ObjectNotFoundException after evicting the cache.

All suggestions on this argument are welcome.

TIA

_________________
--
Marco


Top
 Profile  
 
 Post subject: Re: Evict cache on exception
PostPosted: Mon Sep 19, 2005 3:55 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
marco-p wrote:
Hi all,

I have a cache issue with Hibernate 3.0.5. I've configured a read-write cache on an object that it's externally modified. I know that's a bad idea, 'cause it may produce ObjectNotFoundException if the object is loaded but deleted from db.
What I want to do is to tune the cache usage without disabling it (the table is accessed about 3 times a sec, so it's really important).
The table is updated every hour by a batch process. I think I can manually evict cache for the table when processing ends, but it's still not sure.
I wonder if there's a way to make Hibernate retry the query on a ObjectNotFoundException after evicting the cache.

All suggestions on this argument are welcome.

TIA


Maybe you could set the object in cache to expire every hour or so since the table is updated every hour. So now you will always have the newest object since hibernate will query the database if the object is not found in the cache anyways. Or am I missing something.

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 3:46 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
I've already tried this way, but it's impossible to syncronize the update job with cache expiration, because it depends on the time the object is loaded.
So every setting for cache expiration is wrong, because there's always the possibility to get an error.
So, IMO, the correct approach is to manually evict all object when the job finish (but there's always the possibility to get an error during the update), or retrying a failed query after invalidating the cache. I do not see any other possibility.

_________________
--
Marco


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.