-->
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.  [ 1 post ] 
Author Message
 Post subject: 2nd level read only caching and synchronisation
PostPosted: Thu Feb 01, 2007 5:22 am 
Newbie

Joined: Thu Feb 01, 2007 4:45 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Hi,

I have a query about Hibernate 2nd level caching which I wondered whether anyone knows the answer to?

We have a set of data in a couple of tables in an Oracle database that is maintained by an external application. We don't mind if the application's view of this data is slightly out of date. Therefore, we use Hibernate's Query and 2nd level caches with a cache timeout set to a time period we can live with. Currently, the cache we have plugged in happens to be OSCache.

With the above requirements, it seemed logical that the choice of of caching should be cache-usage="read-only".

With this setting the CacheFactory class creates a ReadOnlyCache class. However, under high load this class became a bottleneck as both its get and put methods are fully synchronised leading to lots of blocked threads all trying to use the get method.

A simple "solution" that seems to work is to change the cache-usage to cache-usage="nonstrict-read-write" which means that the CacheFactory creates a NonStrictReadWriteCache class. This class doesn't synchronise the get and put put methods. When testing the app under high load we no longer get blocking in the Hibernate layer.

So I have a couple of questions if anyone is able to help

a) does anyone know why the ReadOnlyCache class synchronises on both the get and the put methods. My (probably too simplistic) thoughts on this is that it should be the job of the plugged in cache (OSCachee) to peform the synchonisation (hopefully at the "slot" level rather than on the whole cache or cache get/put methods)

b) as we changed to the NonstrictReadWriteCache class, does this mean that Hibernate is now having to do any more work compared to if it was told to use ReadOnlyCache. To clarify, I don't mean extra work in the XxxxxCache class itself (as I've read the code for these classes) - I mean does setting nonstrict-read-write cause Hibernate to perform any other work outside the NonstrictReadWriteCache.

As ever, many thanks for any information anyone can provide.

Cheers

Aidan


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.