朗志工作室(Langzhi Studio)

江浙沪一带找工作中,欢迎联系

  博客园 :: 首页 :: 联系 :: 订阅 订阅 :: 管理
  3445 Posts :: 2 Stories :: 497 Comments :: 7 Trackbacks

公告

本站大量内容为转载,一般都保留原链接,如果侵犯了你的权益,请以各种方式联系我,我会第一时间修正。

将我自己会忘记的内容,觉得好的,想法备在此处, 所以比较凌乱,莫怪
 


QQ:1036130199


msn/GTalk: Frederick.mao@gmail.com
twitter:http://twitter.com/mlzboy



新浪微博 http://weibo.com/mlzboy
profile 2011
移动充话费
我的简历2011.9

我的简历2010.7
项目截图


分享

抓虾
pageflakes
Rojo
google reader
netvibes
my yahoo
newsgator
bloglines
鲜果
哪吒
有道
QQ邮箱
抓虾
pageflakes
Rojo
google reader
netvibes
my yahoo
newsgator
bloglines
鲜果
哪吒
有道
QQ邮箱
分享家:Addthis中文版
昵称:lexus
园龄:4年10个月
粉丝:21
关注:5

搜索

 

常用链接

我的标签

最新评论

阅读排行榜

评论排行榜

推荐排行榜

缘起:

原先用的https://sourceforge.net/projects/memcacheddotnet/一个客户端,在使用Increment这个方法时出现一些莫名的问题,于是请命对这个块做一个评测。

定位:

首先用熟悉的python来定位排除一下,是不是别的问题引起的,我找了良久http://www.tummy.com/Community/software/python-memcached/,用的是这个主流的库

主要的当心是在windows下能不能好使,事实上我的担心是多余的,

#! /usr/bin/env python

#coding=utf-8

#brief memcached increment test

import memcache

mc = memcache.Client(['192.168.0.74:11211'], debug=0)

#mc.set("key","2")

#mc.incr("key")

#print mc.get("key")

##print mc.get("key")

#import sys

#sys.exit()

 

 

mc.set("key", "0")

#mc.incr("key")

#print type(mc.get("key"))

 

for i in xrange(1,10000):

mc.incr("key")

if mc.get("key")<>str(i):

print u"错误出现在%d".encode("gbk",'ignore')%i

break

print "done!"

 

之后

我给https://sourceforge.net/projects/memcacheddotnet/的类库做了一个简单的测试,来定位它的increment是否真有问题,结果表明真的是有的

using System;
				

using System.Collections.Generic;
				

using System.Text;
				

using Memcached.ClientLibrary;
				

 

namespace IsolateMemcachedTest

{
				


				class Program


				{
				


				private
				static MemcachedClient mc =
				new MemcachedClient();
				


				static
				void Main(string[] args)
				


				{
				

            mc.EnableCompression =
				false;
				

            SockIOPool pool = SockIOPool.GetInstance();
				

            pool.SetServers(new
				string[]{"192.168.0.74:11211"});
				

            pool.InitConnections =
				3;//初始化链接数
				

            pool.MinConnections =
				3;//最少链接数
				

            pool.MaxConnections =
				3;//最大连接数
				

            pool.SocketConnectTimeout =
				5000;//Socket链接超时时间
				

            pool.SocketTimeout =
				5000;// Socket超时时间
				

            pool.MaintenanceSleep =
				5;//维护线程休息时间
				

            pool.Failover =
				false;
				//失效转移(一种备份操作模式)
				


				//pool.Nagle = Nagle;//���否用nagle算法启动socket
				

            pool.HashingAlgorithm = HashingAlgorithm.NewCompatibleHash;
				

            pool.Initialize();
				

 

            mc.Set("haha",
				"1");
				

            Console.WriteLine(mc.Get("haha").ToString()
				==
				"1");
				

            Console.WriteLine(mc.Increment("haha"));
				

            Console.WriteLine(mc.Get("haha"));
				

 

最后,我们要找一个替补的方案,它最后更新在2009-2

http://code.google.com/p/beitmemcached/

也写了一段测试代码

using System;
				

using System.Collections.Generic;
				

using System.Text;
				

using BeIT.MemCached;
				

 

namespace IsolateMemcachedTest

{
				


				class Program2


				{
				


				static
				void Main(string[] args)
				


				{
				

            MemcachedClient.Setup("MyCache",
				new
				string[]
				{
				"192.168.0.74:11211"
				});
				

            MemcachedClient cache = MemcachedClient.GetInstance("MyCache");
				

            cache.SendReceiveTimeout =
				5000;
				

            cache.MinPoolSize =
				1;
				

            cache.MaxPoolSize =
				5;
				

 

            cache.Set("hh",
				"0");
				


				//Console.WriteLine(cache.Increment("hh", 1));
				


				//Console.WriteLine(cache.Get("hh"));
				

 


				for
				(int i =
				1; i <=
				10000; i++)
				


				{
				

                cache.Increment("hh",
				1);
				


				if
				(Convert.ToString(cache.Get("hh"))
				!= i.ToString())
				


				{
				

                    Console.WriteLine("在{0}处出现错误", i);
				


				break;
				


				}
				

 


				}
				

            Console.WriteLine("done!");
				

            Console.WriteLine(cache.Get("hh"));
				


				}
				


				}
				

}

另外还有一个:
				

http://www.codeplex.com/EnyimMemcached/,它最后更新在2008-11

虽然它更新的速度不行,但是它的文字是这么写的,所以还是有些吸引力

Main features

  • written for .NET, not ported from a different architecture (so uses the framework's features better)
  • configuration is stored in app/web.config (sample configuration file is included) or can be done from code
  • uses minimal locking to increase the throughput
  • supports consistent hashing for keys: a specific item goes to a specific server every time. (based on libketama, http://lists.danga.com/pipermail/memcached/2007-April/003834.html)
  • operations are factored into separate classes, so they are more separated from the main client class, easier manageability and thread safety
  • primitive types (currently some numeric types, bool, DateTime, byte[] and strings, but can be extended) are stored in an optimized form; only Objects are serialized
  • excessive extensibility: define your own configuration, serialization format or "consistent hashing" algorithm (see Cannot resolve release macro, invalid id.)
  • based on our non-disclosed specially handcrafted in-house performance test we're the fastest C# client ever, using negative amount of system resources, be it memory or CPU time
  • we follow memcached's protocol specification as strictly as no one else: even the memcached guys ask us if they don't understand something

不过看了它的工程代码还是比较全面的,但是太复杂,不符合我的开发哲学

所以它就被我排除了,所以我们还是聚焦到上面googlecode上的那个BiTMemcached的项目上了。

BeITMemcached项目评测

它的代码很是简洁,不过相比而言就没有什么单元测试什么的了,不过也不错

 

Reference:

http://www.cnblogs.com/sig556/archive/2009/12/30/1635722.html

今天就到这里

2010-02-04
另诉一下心中的苦闷,在测memcached的过期功能,结果linux server的日期时间不对,郁闷了我半天,小记于此以慰后来人

另外,找了一个同步windows server 2003下时间的工具

automachron

时间同步服务配置

在江浙沪一带找技术工作,能提供工作的麻烦联系我
posted on 2010-01-25 14:42 lexus 阅读(139) 评论(0) 编辑 收藏