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.  [ 7 posts ] 
Author Message
 Post subject: Nhibernate and memcached bug
PostPosted: Sun Oct 01, 2006 7:47 pm 
Newbie

Joined: Sun Oct 01, 2006 7:29 pm
Posts: 3
Hi I have been using NHibernate for about a week now and I must say it's an outstanding product. I am using NHibernate 1.2.0 Beta1. But I think I found a bug regarding to caching. I was trying to get Memcached caching to work and found that no connections are made to memcached server. After debugging the source for a while I found that the problem occurs because no call is made to the ICacheProvider.Start( IDictionary properties ) method of NHibernate.Caches.MemCache.MemCacheProvider class where a lot of memcached client initialization work is done. Can anybody confirm this error and tell where do I need to call this method - I think it's needed to call it during the initialization of ISessionFactory.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 2:47 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
What does your config look like? I just want to rule out a simple config issue first.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 3:19 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
After using ReSharper to trace usages through the entire code base, it seems to me that CacheFactory.CreateCache, around line 78, should call the ICacheProvider.Start method.

I'd like to have Sergey or someone more familiar with the NHibernate core code verify this, but IMHO this is an NHibernate bug.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 1:28 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You were right. I have fixed this in SVN now, calling CacheProvider.Start in the constructor of SessionFactoryImpl.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 2:24 am 
Newbie

Joined: Sun Oct 01, 2006 7:29 pm
Posts: 3
Thanks for replies - got memcached partially working and I'll try to find out why I get a stream write error. Another thing is the documentation. There is no info about configuring memcached -is there a way to contribute to documentation or could somebody do it? I had to debug and read the source to get it configured. My configuration is like this.

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"></section>
<section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler, NHibernate.Caches.MemCache" />
</configSections>

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >
<session-factory>
NHibernate configuration here....
</session-factory>
</hibernate-configuration>

<memcache>
<memcached host="192.168.1.20" port="11211" weight="1" />
</memcache>
</configuration>
And I couldn't really understand what does the weight setting mean. Could somebody explain that to me?

Regards Andri.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 2:25 am 
Newbie

Joined: Sun Oct 01, 2006 7:29 pm
Posts: 3
Thanks for replies - got memcached partially working and I'll try to find out why I get a stream write error. Another thing is the documentation. There is no info about configuring memcached -is there a way to contribute to documentation or could somebody do it? I had to debug and read the source to get it configured. My configuration is like this.

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"></section>
<section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler, NHibernate.Caches.MemCache" />
</configSections>

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >
<session-factory>
NHibernate configuration here....
</session-factory>
</hibernate-configuration>

<memcache>
<memcached host="192.168.1.20" port="11211" weight="1" />
</memcache>
</configuration>


And I couldn't really understand what does the weight setting mean. Could somebody explain that to me?

Regards Andri.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 9:50 am 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Regarding the documentation and getting up to speed, the unit tests are always the best place to start. There shouldn't be anything in NHibernate that isn't unit tested (if possible), and the tests should work. These are great examples of how the code should work and how it should be used.

The official memcached site is http://www.danga.com/memcached/, and the .NET client is at http://sourceforge.net/projects/memcacheddotnet/. Documentation is very scarce, but fortunately memcached is pretty easy to use.

I'd say the memcache 2nd-level cache is less than alpha - let's call it 'experimental' for now. In other words, try it, see if it works, and let us know.


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