安装Cache::Memcahced模块
首先安装配置cpan,使用cpan来安装Cache::Memcahced模块
yum -y install cpan
vim /usr/share/perl5/CPAN/Config.pm
将镜像路径设置为:
'urllist' => [q[http://mirrors.ustc.edu.cn/CPAN/]],
安装:
perl -MCPAN -e shell
cpan[1]> install Cache::Memcahced
开始安装……
创建perl文件执行测试:
vim mem.pl
内容如下:
#!/usr/bin/perl
use Cache::Memcached;
my $key = "foo";
my $value = "bar";
my $expires = 3600; # 1 hour
my $memcached = Cache::Memcached->new({
servers => ["127.0.0.1:11211"],
compress_threshold => 10_000
});
$memcached->add($key, $value, $expires);
my $ret = $memcached->get($key);
print "$retn";
执行mem.pl输出内容为bar说明正确;