Skip to content

Enyim Memcached 客户端几点偶遇

二进制协议

MemcachedClientConfiguration.Protocol = Binary,这是新版默认配置,但是如果你的Memcached版本不是在1.3以上,将无法支持二进制协议传输模式,特别是Memcached for win32 好像还是处于1.2.4版本上,这里只能需要配置 MemcachedClientConfiguration.Protocol = Text。

Get泛型

我是第一次使用这个版本的客户端,这里有个比较好的就是支持泛型的获取数据。基本实现方式:

return TryGet(key, out tmp) ? (T)tmp : default(T);

而Get

return this.TryGet(key, out tmp) ? tmp : null;

因此在本质上并没有太多的区别,减少类型转换,我建议使用as简单明了。

尽量只创建过少的MemcachedClient

Enyim.MemcachedClient支持不同池配置,我建议对每个Client做Singleton模式。

配置问题

其实我不想说这个事,但是我只是想提醒一下,Enyim.MemcachedClient在配置时,都是对套接字池的配置(即:Scoket Pool),对于入门来讲只要了解.NET中的套接字池配置就可以,哪怕不通过Web.Config,也可以通过很简单的MemcachedClientConfiguration.SocketPool套接字池配置,因些不要太过于复杂化。

相关日志

Categories: 技术.

Tags:

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word