views:

230

answers:

1

where can i find SharedCache with fluent nhibernate getting started guid

+3  A: 

There is very little documentation I've found for getting SharedCache working with NHibernate, let alone doing it fluently. However, it's not a hard process:

  1. You need to tell NHibernate you're using SharedCache as a cache provider. Another Stack Overflow answer gives a sample implementation for Fluent NHibernate. The key bit is the Cache function, except here you will want to use NHibernate.Caches.SharedCache.SharedCacheProvider instead of NHibernate.Cache.HashtableCacheProvider.

    As an aside, to configure it non fluently you use something like this in your configuration:

    <add key="hibernate.cache.provider_class" value="NHibernate.Caches.SharedCache.SharedCacheProvider, NHibernate.Caches.SharedCache" />
    

    Or, if you're configuring via Spring.NET with the rest of your NHibernate configuration entries:

    <entry key="cache.provider_class" value="NHibernate.Caches.SharedCache.SharedCacheProvider, NHibernate.Caches.SharedCache" />
    
  2. You will then need to add web.config / app.config entries for the cache as you would when using SharedCache without NHibernate, for example:

    <configSections>
        <section name="indexusNetSharedCache" type="MergeSystem.Indexus.WinServiceCommon.Configuration.Client.IndexusProviderSection, MergeSystem.Indexus.WinServiceCommon" />
    </configSections>
    
    
    <indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
        <servers>
            <add key="myServer1" ipaddress="127.0.0.1" port="48888"/>
        </servers>
        <providers>
            <add name="IndexusSharedCacheProvider" type="MergeSystem.Indexus.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, MergeSystem.Indexus.WinServiceCommon" />
        </providers>
    </indexusNetSharedCache>
    

You can find plenty more information about configuring a SharedCache client on their website, although be sure to configure each server too.

Hope this helps - I haven't been able to fully test this, so I may've made a mistake somewhere.

Simon Rice