-->
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.  [ 4 posts ] 
Author Message
 Post subject: ehcache: many puts, no hits, no elements in memory
PostPosted: Fri Jun 19, 2009 10:57 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
Hi,

I am trying to setup ehcache with hibernate and it seems that it is not working properly. When I take a look at the generated statistics, it shows a huge number of puts (about 30.000), but only a few hundret hits and misses (about 300-400). Also, there are practically no elements in the cache (< 10).

The cache has been configured with eternal element lifetime without disk usage. How can it happen, that elements are removed from the cache after they have once been put into? Should not the number of elements be at least equal to the number of misses? Because for every miss, the element is loaded and the put into the cache.

Anyone who could give me an idea?


Top
 Profile  
 
 Post subject: Re: ehcache: many puts, no hits, no elements in memory
PostPosted: Fri Jun 19, 2009 11:08 am 
Newbie

Joined: Mon Oct 27, 2008 2:43 am
Posts: 7
Hi,

For the elements to be cached and retrieved from the cache, you have to load them by their id.
Are you doing so?

_________________
-GJ


Top
 Profile  
 
 Post subject: Re: ehcache: many puts, no hits, no elements in memory
PostPosted: Fri Jun 19, 2009 12:39 pm 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
I am issuing an HQL query that loads all objects of the given type. Basically something like this:
Code:
Query query = session.createQuery("from MyMappedClass")
query.setCacheable(true);
List result = query.list();


Top
 Profile  
 
 Post subject: Re: ehcache: many puts, no hits, no elements in memory
PostPosted: Mon Jun 22, 2009 6:12 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
I found the reason myself, so here it is:

Before executing the actual query, I was modifying the session to use binary sorting:
Code:
SQLQuery sqlQuery = session.createSQLQuery("alter session set nls_sort=binary");
sqlQuery.executeUpdate();

Hibernate thinks this executeUpdate() statement as a bulk data modification, that goes past the cache. Thus, the cache is considered as possibly out of sync with the underlying actual data and is cleared. Thus, many puts during the session, but at the end, no elements at all in the cache.


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