我已经设法在 FHN 中为 Get\Load 配置 L2 缓存,但它不适用于使用 ICriteria 接口配置的查询 - 它不会缓存这些查询的结果。
有谁知道为什么?
配置如下:
标准:
return unitOfWork
.CurrentSession
.CreateCriteria(typeof(Country))
.SetCacheable(true);
实体映射:
public sealed class CountryMap : ClassMap<Country>, IMap
{
public CountryMap()
{
Table("Countries");
Not.LazyLoad();
Cache.ReadWrite().IncludeAll();
Id(x => x.Id);
Map(x => x.TwoLetter);
Map(x => x.ThreeLetter);
Map(x => x.Name);
}
}
以及数据库属性的会话工厂配置:
return () => MsSqlConfiguration.MsSql2005
.ConnectionString(BuildConnectionString())
.ShowSql()
.Cache(c => c.UseQueryCache()
.QueryCacheFactory<StandardQueryCacheFactory>()
.ProviderClass(configuration.RepositoryCacheType)
.UseMinimalPuts())
.FormatSql()
.UseReflectionOptimizer();
干杯
AWC