Hibernate Books

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Weird differences between SysCache and SysCache2
PostPosted: Tue Nov 06, 2007 3:40 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:38 am
Posts: 28
I'm currently trying to get a 2nd level cache running correctly. I started using SysCache2 but got nowhere. Then I switched back to SysCache because I figured cache expiration can wait until I got the caching right in the first place. So after long try-and-error I got SysCache working the way I wanted it.

More spefically I have a parent child relationship, where the child objects are eagerly fetched with a subselect. Furthermore, I made the following changes:

-Attributed both parent and child object with
[Cache(1, Region = "KnowledgeRegion", Usage = CacheUsage.ReadWrite)]

-Annotated the child collection with Cache
[Bag(0, Cascade = CascadeStyle.All, OrderBy = "Name asc", Fetch = CollectionFetchMode.Subselect, Lazy = false)]
[Cache(1, Region = "KnowledgeRegion", Usage = CacheUsage.ReadWrite)]
[Key(2, Column = "ForeignID")]
[OneToMany(3, ClassType = typeof(SearchExpressionEntry))]
public IList SearchExpressions {}

-Used .SetCacheable(true).SetCacheRegion("KnowledgeRegion") in the ICriteria query that's retrieving the parent objects

-Changed the web.config file:
<syscache>
<cache region="KnowledgeRegion" expiration="300" priority="3" />
</syscache>


So with the first request I see two SELECT statements and after that no more selects until the cache expired. After that I see the same two SELECT statements again that were submitted in the beginning.

Now to my problem. I'd really like to use the SqlDependency features supported by SysCache2. But if I switch over to SysCache2 some "things" don't seem to get cached. The first request results in the same two SELECT statements. But then for the second request NHibernate requeries every single parent object and its child objects so I have 2 * nParent queries.

The SysCache2 configuration looks like this:
<syscache2>
<cacheRegion name="KnowledgeRegion">
<dependencies>
<tables>
<add name="Fault" databaseEntryName="AISDB" tableName="Fault" />
<add name="SearchExpression" databaseEntryName="AISDB" tableName="SearchExpression" />
</tables>
</dependencies>
</cacheRegion>
</syscache2>


From what I remember I saw a similar behavior using SysCache when I did not specify the cache regions correctly during my try-and-error phase. This was because query results and record data then timed out at different times. But I'm not sure whether it was EXACTLY the same problem/behavior.

I doubt that it has something to do with cache expiry notifications received from a SqlDependency. If there was an expiration I'd expect that NHibernate just submits the two SELECT statements from before. Additionally, since everything is tied to the KnowledgeRegion region, everything should expire. But here it seems the query results are still available but the object data is not.

So, my question is did I do anything wrong or forget something when switching to SysCache2 or is there a problem in SysCache2?

Thanks a lot, Christoph


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

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.