#!perl
use strict;
use Cache::Memcached::Fast;
sub getConfig{
return ["xx.xx.xx.201:11211","xx.xx.xx.203:11211","xx.xx.xx.204:11211","xx.xx.xx.205:11211","xx.xx.xx.206:11211","xx.xx.xx.207:11211","xx.xx.xx.208:11211","xx.xx.xx.218:11211","xx.xx.xx.235:11211","xx.xx.xx.236:11211","xx.xx.xx.237:11211","xx.xx.xx.238:11211","xx.xx.xx.239:11211","xx.xx.xx.240:11211"];
}
my $memcached ;
my $expires = 1800;
my $memcached =Cache::Memcached::Fast->new({ servers =>getConfig(), ketama_points => 151});
my @addMutiKeys=();
my @addMutiExipres=();
my @addMutiValues=();
my $addMultiStr="";
my $split="";
for ( my $i = 0 ; $i < 10000 ; $i++ ) {
my $index=$i;
push(@addMutiKeys,"myn_key_".$index);
push(@addMutiValues,"myn_value_".$index);
push(@addMutiExipres,3600);
$addMultiStr=$addMultiStr.$split."[\""."myn_key_".$index."\",\"1\",3600]";
$split=",";
}
#my $hashKeys=$memcached->add_multi(["aaa","111",3600],["bbb","222",3600]);
#my $hashKeys=$memcached->add_multi(map { [$addMutiKeys[$_], "aa"] } @addMutiValues);
#$hashKeys=$memcached->get_multi(@addMutiKeys);
my $hashKeys;
my $evalStr="return \$memcached->add_multi($addMultiStr);";
$hashKeys=eval($evalStr);
my $i=0;
for($i=0;$i<@addMutiKeys;$i++)
{
#print $addMutiKeys[$i]."\n";
}
my $ekey;
foreach $ekey (keys(%$hashKeys))
{
print "key=".$ekey."[".$$hashKeys{$ekey}."]\n";
}
$memcached->disconnect_all();
use strict;
use Cache::Memcached::Fast;
sub getConfig{
return ["xx.xx.xx.201:11211","xx.xx.xx.203:11211","xx.xx.xx.204:11211","xx.xx.xx.205:11211","xx.xx.xx.206:11211","xx.xx.xx.207:11211","xx.xx.xx.208:11211","xx.xx.xx.218:11211","xx.xx.xx.235:11211","xx.xx.xx.236:11211","xx.xx.xx.237:11211","xx.xx.xx.238:11211","xx.xx.xx.239:11211","xx.xx.xx.240:11211"];
}
my $memcached ;
my $expires = 1800;
my $memcached =Cache::Memcached::Fast->new({ servers =>getConfig(), ketama_points => 151});
my @addMutiKeys=();
my @addMutiExipres=();
my @addMutiValues=();
my $addMultiStr="";
my $split="";
for ( my $i = 0 ; $i < 10000 ; $i++ ) {
my $index=$i;
push(@addMutiKeys,"myn_key_".$index);
push(@addMutiValues,"myn_value_".$index);
push(@addMutiExipres,3600);
$addMultiStr=$addMultiStr.$split."[\""."myn_key_".$index."\",\"1\",3600]";
$split=",";
}
#my $hashKeys=$memcached->add_multi(["aaa","111",3600],["bbb","222",3600]);
#my $hashKeys=$memcached->add_multi(map { [$addMutiKeys[$_], "aa"] } @addMutiValues);
#$hashKeys=$memcached->get_multi(@addMutiKeys);
my $hashKeys;
my $evalStr="return \$memcached->add_multi($addMultiStr);";
$hashKeys=eval($evalStr);
my $i=0;
for($i=0;$i<@addMutiKeys;$i++)
{
#print $addMutiKeys[$i]."\n";
}
my $ekey;
foreach $ekey (keys(%$hashKeys))
{
print "key=".$ekey."[".$$hashKeys{$ekey}."]\n";
}
$memcached->disconnect_all();
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/3402/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表