如何在NHibernate> = 3.2中配置NHibernate的二级缓存? [英] How to configure NHibernate's Second Level Cache in NHibernate >= 3.2?
本文介绍了如何在NHibernate> = 3.2中配置NHibernate的二级缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
OracleClientConfiguration configurer =(OracleClientConfiguration.Oracle10。)在升级到NHibernate 3.2之前,我使用了以下代码: ShowSql().ConnectionString(c =>
c.FromConnectionStringWithKey(ConnectionString.Development))
.DefaultSchema(MySchema)
.UseReflectionOptimizer()
/ * Here - - > * / .Cache(c =>
c.ProviderClass< SysCacheProvider>()
.UseQueryCache()));
但是, .Cache()
扩展名方法不再在NHibernate 3.2中找到。
如何设置我的缓存提供程序?
编辑:我也试过:
.ExposeConfiguration(configuration =>
{
configuration.SetProperty(Environment.UseQueryCache,true);
configuration.SetProperty(Environment.CacheProvider,NHibernate.Caches.SysCache.SysCacheProvider,NHibernate.Caches.SysCache2);
});
解决方案
这是我的配置摘录,使用SysCache提供者。
var configuration = new Configuration()
.Cache(x => x.UseQueryCache = true)
configuration.SessionFactory()
.Caching.Through< SysCacheProvider>()。WithDefaultExpiration(60)
Before upgrading to NHibernate 3.2, I used the following code for Fluent NHibernate:
OracleClientConfiguration configurer = (OracleClientConfiguration.Oracle10.ShowSql().ConnectionString(c =>
c.FromConnectionStringWithKey(ConnectionString.Development))
.DefaultSchema("MySchema")
.UseReflectionOptimizer()
/* Here --> */ .Cache(c =>
c.ProviderClass<SysCacheProvider>()
.UseQueryCache()));
However, the .Cache()
extension method is no longer found in NHibernate 3.2.
How would do I setup my cache provider?
Edit: I also tried:
.ExposeConfiguration(configuration =>
{
configuration.SetProperty(Environment.UseQueryCache, "true");
configuration.SetProperty(Environment.CacheProvider, "NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache2");
});
解决方案
This is an excerpt from my configuration, using the SysCache provider.
var configuration = new Configuration()
.Cache(x => x.UseQueryCache = true)
configuration.SessionFactory()
.Caching.Through<SysCacheProvider>().WithDefaultExpiration(60)
这篇关于如何在NHibernate> = 3.2中配置NHibernate的二级缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文