Hello

Did't get any QueryCacheHitCount. The Source Code looks like:

Factory = Fluently.Configure()
    .ExposeConfiguration(c =>
        c.SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, 
"true"))
    .Database(
    MsSqlConfiguration.MsSql2008.ConnectionString(c => c.Is("DATA 
SOURCE=localhost;PERSIST SECURITY INFO=True;USER ID=AAA;Password=AAA"))
            .ShowSql()
    )
    .Mappings(x => 
x.FluentMappings.AddFromAssemblyOf<Localization.NHibernate.Article>())
    .ExposeConfiguration(BuildDatabase)
    .Cache(
        x => x.UseSecondLevelCache()
                .UseQueryCache()                          
                .ProviderClass<NHibernate.Cache.HashtableCacheProvider>())
    .BuildSessionFactory();



using (var tx = session.BeginTransaction())
{
    Factory.Statistics.Clear();

    for (int i = 0; i < 10; i++)
    {
        Article s = session.Query<Article>().Cacheable().Where(x => x.Name 
== "O").SingleOrDefault();
    }

    Console.WriteLine(Factory.Statistics.QueryCacheHitCount);
    Console.WriteLine(Factory.Statistics.SecondLevelCacheHitCount);
    Console.WriteLine(Factory.Statistics.QueryExecutionCount);
}

===================================================================================

Only if i change the cache config and add my private QueryCacheFactory with 
".QueryCacheFactory<CacheFactory>()" than it works

public class CacheFactory : NHibernate.Cache.IQueryCacheFactory
{
    public NHibernate.Cache.IQueryCache GetQueryCache(string regionName, 
NHibernate.Cache.UpdateTimestampsCache updateTimestampsCache, Settings 
settings, IDictionary<string, string> props)
    {
        return new MyStandardQueryCache(settings, props, 
updateTimestampsCache, regionName);
    }

    private class MyStandardQueryCache : NHibernate.Cache.StandardQueryCache
    {
        public MyStandardQueryCache(Settings settings, IDictionary<string, 
string> props, NHibernate.Cache.UpdateTimestampsCache 
updateTimestampsCache, string regionName)
            : base(settings, props, updateTimestampsCache, regionName) { }

        protected override bool 
IsUpToDate(Iesi.Collections.Generic.ISet<string> spaces, long timestamp)
        {
            *return true;* // SET TO TRUE than it's hitting the cache
        }
    }
}


hope anyone can help

rgds

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/0GtxNZgyixkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to