Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2796807
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: PERL

2014-08-22 21:50:54

                               PERL与memcached集成

     安装perl的memached的模块  Cache::Memcached


[root@c12 0822]# perl  -MCPAN  -e "install Cache::Memcached"


..................


t/06_utf8_key.............skipped
        all skipped: No memcached instance running at 127.0.0.1:11211
t/100_flush_bug...........ok                                                
t/101_multiple_clients....skipped
        all skipped: cannot connect to 127.0.0.1:11211
All tests successful, 5 tests skipped.
Files=8, Tests=10,  4 wallclock secs ( 0.33 cusr +  0.05 csys =  0.38 CPU)
  /usr/bin/make test -- OK
Running make install
Manifying blib/man3/Cache::Memcached.3pm
Installing /usr/lib/perl5/site_perl/5.8.8/Cache/Memcached.pm
Installing /usr/lib/perl5/site_perl/5.8.8/Cache/Memcached/GetParser.pm
Installing /usr/share/man/man3/Cache::Memcached.3pm
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Cache/Memcached/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
  /usr/bin/make install  -- OK


看起来已经可以了,确认一下模块是不是正常安装

[root@c12 0822]# perldoc perllocal | grep Mo
       Sun May  4 13:25:53 2014: "Module" percona-toolkit
       Thu May 22 12:32:33 2014: "Module" Test::Tester
       Thu May 22 12:33:30 2014: "Module" Test::Simple
       Thu May 22 12:33:31 2014: "Module" Test::NoWarnings
       Thu May 22 12:33:33 2014: "Module" Test::Deep
       Thu May 22 12:38:32 2014: "Module" DBI
       Thu May 22 12:42:43 2014: "Module" DBD::mysql
       Fri Aug 22 13:21:02 2014: "Module" Cache::Memcached


写个小程序来试一下,看一下工作是否正常

#!/usr/bin/perl -w
#writen by dongdongtang

use strict;
use Cache::Memcached;

my $cache=new Cache::Memcached {
       'servers'=>['127.0.0.1:11211',],};
my $i='abc';

if ($cache->set($i,'asdf'))

       { printf "store data in memcache ok\n";}

  else
       { printf "can not store in memcache\n";}
~

[root@c12 0822]# ./1.pl
store data in memcache ok

使用telnet来检查一下成果

[root@c12 ~]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
get abc
VALUE abc 0 4
asdf
END

 


 

阅读(2311) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~