-->
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.  [ 6 posts ] 
Author Message
 Post subject: Is caching really good (discussion)?
PostPosted: Fri Nov 21, 2003 5:34 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
I have some doubts on caching and would like to dicuss them with the Hibernate community.

1)
If we have a session cache level and supposing I have session instance per method, then where are the cached objects so they can be used between sessions?

2)
If the cache is never aware of changes made to the persistent store by another process, then we could be accessing old data. Even with a small expire time there could be the possibility a process can access old data. But if we put a small expire time for the cache, then what is the cache good for if the cached objects expire quickly.


Top
 Profile  
 
 Post subject: and...
PostPosted: Fri Nov 21, 2003 10:36 am 
Regular
Regular

Joined: Wed Sep 10, 2003 7:09 am
Posts: 63
3) The significant memory occupied by those objects in cache...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 3:10 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
I don't think the session-level cache is optional from an architectural standpoint:

http://forum.hibernate.org/viewtopic.php?t=925665


Top
 Profile  
 
 Post subject: Re: Is caching really good (discussion)?
PostPosted: Fri Nov 21, 2003 3:32 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
nerotnt wrote:
1) If we have a session cache level and supposing I have session instance per method, then where are the cached objects so they can be used between sessions?


In case of a Hibernate transaction that associates a database transaction with a ThreadLocal Session (like implemented by the Spring Framework), all data access methods that participate in a transaction will share the same Session. But generally, the Session is a means for consistency rather than long-term caching in the typical sense.

nerotnt wrote:
2) If the cache is never aware of changes made to the persistent store by another process, then we could be accessing old data. Even with a small expire time there could be the possibility a process can access old data. But if we put a small expire time for the cache, then what is the cache good for if the cached objects expire quickly.


That's of course true for a JVM-level cache, and represents the typical tradeoff when using a cache. But for the Session-level cache, you can avoid staleness of data by setting a proper database transaction isolation level, provided that the scope of your transaction matches with the lifetime of your Session.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 5:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is not a matter of "is caching" good, but more a matter or what kind of caching should be used for what kinds of objects.


Top
 Profile  
 
 Post subject: Re: Is caching really good (discussion)?
PostPosted: Fri Nov 21, 2003 7:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
nerotnt wrote:
2)
If the cache is never aware of changes made to the persistent store by another process, then we could be accessing old data. Even with a small expire time there could be the possibility a process can access old data. But if we put a small expire time for the cache, then what is the cache good for if the cached objects expire quickly.

Optimistic locking is here to keep consistency and thus allow you to increase your expiration time.

_________________
Emmanuel


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