这大体上可以看出,服务器端口缓存技术。 memcached 官方:http://www.danga.com/memcached/ 安装前,先安装 其上为 linux 软件一般安装,看他们readme文档 $>memcached -d -u nobody -m 512 127.0.0.1 -p 11211 如果有异常, ln -s /usr/local/lib/libevent-1.4.so.2 /lib/libevent-1.4.so.2 参考 http://blog.chinaunix.net/u2/70049/showart_1665279.html 我这就使用 perl 语言了, 其他语言参考 http://code.google.com/p/memcached/wiki/Clients perl 使用 cpan> install Cache :: Memcached ;#会使用 perl 我就不说了 代码说明:不停对 key 为test 的值进行递增 # !/bin/perl -w use Cache :: Memcached; my $memd = new Cache :: Memcached{servers => [ ' 127.0.0.1:11211 ' ] }; my $key = ' test ' ; $memd -> add( $key => 1 , 3600 ) or warn ' Alread added ' ; while ( 1 ){ print $memd -> get( $key ) , " \n " ; $memd -> incr( $key ) or warn ' FAIL! ' ; } 使用 telnet 127.0.0.1 11211 $> get test VALUE test 0 2 97 #这就是我们递增的值,当然你使用什么语言取都是一样的
本文转自博客园刘凯毅的博客,原文链接:,如需转载请自行联系原博主。