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.  [ 2 posts ] 
Author Message
 Post subject: second level cache with multiple ISessionFactory instances
PostPosted: Tue Aug 08, 2006 9:02 pm 
Newbie

Joined: Tue Aug 08, 2006 8:45 pm
Posts: 3
i am using nhibernate 1.0.2 and my second level cache is SysCache

my application has multiple databases with the same structure, each with its own ISessionFactory

i seem to be getting cache interactions between sessionfactorys

eg
if i persist an object {type=foo, id=1} to database-a, then that object will be found when i query against databse-b which contains no such object


as a work-around, i have forced each database to have disjoint id-spaces. this successfully hides the cache issue


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 10:01 pm 
Newbie

Joined: Tue Aug 08, 2006 8:45 pm
Posts: 3
the source for NHibernate.Cfg.Configuration::ConfigureCaches() hinted at a solution, which was to add the ability to configure cache_region_prefix

this was quite easily done by adding a wrapper to SysCacheProvider:

Code:
public class CacheProvider : ICacheProvider
{
   private SysCacheProvider provider = new SysCacheProvider();

   public ICache BuildCache( string regionName, IDictionary properties )
   {
      string prefix = "";
      if (properties.Contains("hibernate.cache.prefix")) {
         prefix = Convert.ToString(properties["hibernate.cache.prefix"]);
      }
      regionName = prefix + regionName;

      return provider.BuildCache( regionName, properties );
   }

   public long NextTimestamp()
   {
      return provider.NextTimestamp();
   }

   public void Start( IDictionary properties )
   {
      provider.Start( properties );
   }

   public void Stop()
   {
      provider.Stop();
   }
}


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