NHibernate and Memcached - Tutorial/Example

后端 未结 1 1719
青春惊慌失措
青春惊慌失措 2021-02-01 09:50

I have the Membase server installed with a couple buckets setup and I was looking for a good tutorial or example of how to use this as the 2nd level cache with NHibernate.

1条回答
  •  时光说笑
    2021-02-01 10:46

    In your mapping files, you will need to include the property:

    
       
       
    
    

    Options are read-write (read committed isolation), nonstrict-read-write (objects that are rarely written, better performance but increased chance of stale data), or read-only (data that never changes).

    Then, in your web (or app) config you need a section to configure memcached:

    
      
        
        

    Finally, in your session factory configuration be sure to use:

      
        
          
    
          300 
          NHibernate.Caches.MemCache.MemCacheProvider,NHibernate.Caches.MemCache
          true
          false 
        
      
    

    Of course you will need to download and reference a dll from the appropriate version of NHibernate.Caches to get the right cache provider. The memcached one takes a dependency on ICSharpCode.SharpZipLib and Memcached.ClientLibrary as well (s/b included in the download)

    If you're using fluent NHibernate, there is a .Cache method in the setup chain for a session factory that you can use, though some of the properties need to be set manually through a call to .ExposeConfiguration.

    0 讨论(0)
提交回复
热议问题