带Protobuf-net.Enyim的NHibernate MemCached-实际起作用吗? [英] NHibernate MemCached w/ Protobuf-net.Enyim -- does it actually work?

查看:126
本文介绍了带Protobuf-net.Enyim的NHibernate MemCached-实际起作用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下程序集使用Protobuf-net二进制序列化程序通过Enyim Memcached连接NHibernate 2级缓存:

I've used the following assemblies to hook up NHibernate 2nd-level caching with Enyim Memcached using Protobuf-net binary serializer:

  • NHibernate
  • NHibernate.Caches.EnyimMemcached
  • Enyim.Caching
  • protobuf-net
  • protobuf-net.Enyim

最近引起我注意的是,尽管将protobuf-net与EnyimMemcached进行了连接,但由于我的所有实体都只标记了[Serializable],而[DataContract][ProtoContract]都没有标记,因此我实际上可能没有使用该序列化器.为属性订购了Data/ProtoMembers.添加适当的属性(或通过RuntimeTypeModel.protobuf-net的默认类手动注册)后,直接与内存缓存进行交互时,我可以使protobuf-net与EnyimMemcached一起使用.

It's recently come to my attention that despite hooking up protobuf-net with EnyimMemcached, I'm likely not actually using that serializer as all my entities were marked with just [Serializable] and neither [DataContract] or [ProtoContract] with corresponding ordered Data/ProtoMembers for the properties. I can get protobuf-net to work with EnyimMemcached when I interact with the memcache directly after I add the appropriate attributes (or register them manually with the RuntimeTypeModel.Default class of protobuf-net).

但是,即使我尽力向protobuf-net注册我的类型,我也不认为任何来自NHibernate的缓存条目实际上都将被protobuf-net序列化,因为NHibernate.Caches.EnyimMemcached将条目存储在DictionaryEntry对象内的缓存:

However, even if I do the due-diligence with registering my types with protobuf-net, I don't think any cache entry coming from NHibernate will actually be serialized by protobuf-net because NHibernate.Caches.EnyimMemcached stores entries in the cache within DictionaryEntry objects:

bool returnOk = client.Store(
    StoreMode.Set, KeyAsString(key),
    new DictionaryEntry(GetAlternateKeyHash(key), value),
    TimeSpan.FromSeconds(expiry));

DictionaryEntry没有[DataContract][DataMember(Order = xx)]属性.这让我感到奇怪...

DictionaryEntry does not have [DataContract] and [DataMember(Order = xx)] attributes. This makes me wonder...

我能否甚至将protobuf-net序列化程序正确地用于NHibernate 2级缓存?

推荐答案

由于没有人回答您的问题,在此我不妨介绍我的两点.我对Memcached作为二级缓存了解不多,但是有强大的缓存解决方案,这些解决方案需要最少的代码更改就可以开始用作二级缓存,并且序列化由缓存处理.您可以将 NCache用作NHibernate的2级缓存

Since no one has answered your question, I might as well give my two bits in here. I don't know much about Memcached as a 2nd level cache but there are powerful caching solutions out there that require minimal code changes to start using as a level 2 cache and serialization is handled by the cache. You can use NCache as a level 2 cache for NHibernate

这篇关于带Protobuf-net.Enyim的NHibernate MemCached-实际起作用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆