I'm trying to implement Nhibernate 2nd level cache using the NHibernate.Caches.Velocity and discussed here on stack overflow using this this blog post.

The application is Azure WebRole using Nhibernate 3.2.

Everything seems to be correct except for an exception that is being thrown when initializing the Session Factory:

"This operation is not supported by the cache."

Stack trace:

at Microsoft.ApplicationServer.Caching.DataCacheFactory.ThrowNotSupportedException()
   at Microsoft.ApplicationServer.Caching.DataCacheFactory.CreateHybridClient(String cacheName, NamedCacheConfiguration config, SimpleSendReceiveModule sendRcvModule)
   at Microsoft.ApplicationServer.Caching.DataCacheFactory.CreateNewCacheClient(DataCacheDeploymentMode mode, String cacheName, NamedCacheConfiguration config, SimpleSendReceiveModule sendRcvModule)
   at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName)
   at NHibernate.Caches.AppFabric.AppFabricCacheFactory.GetCache(String cacheName, Boolean useDefault)
   at NHibernate.Caches.AppFabric.AppFabricCacheAdapter..ctor(String regionName)
   at NHibernate.Caches.AppFabric.Adapters.AppFabricCacheNamedAdapter..ctor(String regionName)
   at NHibernate.Caches.AppFabric.AppFabricCacheAdapterFactory.Create(String regionName)
   at NHibernate.Caches.AppFabric.AppFabricProvider.BuildCache(String regionName, IDictionary`2 properties)
   at NHibernate.Cache.UpdateTimestampsCache..ctor(Settings settings, IDictionary`2 props)
   at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
   at NHibernate.Cfg.Configuration.BuildSessionFactory()
   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 230

Web.Config:

  <dataCacheClients>
    <dataCacheClient name="default">
      <hosts>
        <host name="xxx.cache.windows.net" cachePort="22233" />
      </hosts>
      <securityProperties mode="Message">
        <messageSecurity
          authorizationInfo="xxx">
        </messageSecurity>
      </securityProperties>
    </dataCacheClient>
  </dataCacheClients>

Does anyone have a clue what is causing this? I get zero relevant results if i google it.

有帮助吗?

解决方案

I can't say for sure as I'm not familiar with the way NHibernate tries to use the cache, but the Azure Caching doesn't support all of the functionality of an on premise Cache. I'd guess that it's trying to make use of the unsupported functions. MS have a list of the differences between the two

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top