Skip to content

Instantly share code, notes, and snippets.

@ajohnstone
Last active December 11, 2015 03:28
Show Gist options
  • Save ajohnstone/4538012 to your computer and use it in GitHub Desktop.
Save ajohnstone/4538012 to your computer and use it in GitHub Desktop.
#!/opt/perl/bin/perl
use Cache::Memcached::libmemcached;
use POSIX qw/strftime/;
use Digest::MD5 qw(md5 md5_base64 md5_hex);
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep
clock_gettime clock_getres clock_nanosleep clock
stat );
use Data::Dumper;
sub _log {
print strftime('%Y-%m-%d %H:%M:%S',localtime) . " - @_\n";
}
my $memd = Cache::Memcached::libmemcached->new({
servers => [ "0.0.0.0:11211" ],
compress_threshold => 10_000
});
_log("Generating");
my %data = ();
for(0..20000) {
my $hash = md5_hex( time() . int(rand(1010099000)) ) ;
$data{$hash} = 111111111111;
$memd->set($hash, $data{$hash});
}
#print Dumper(\%data);
_log("Generated");
my $i = 10000;
do {
_log("Getting Slice smaller key ({$i})");
$i-=500;
# my $hashref = $memd->get_multi(@keys);
#print Dumper( @{[keys %data]}[0..100] );
my $result = $memd->get_multi( @{[keys %data]}[0..$i] );
my $cnt = scalar(keys $result) - 1;
_log("Result cnt: $cnt Cas cnt:$i\n");
# print Dumper(%result);
if ($i <=500) {
$i+=500;
$i-=100;
}
if ($i<=200) {
$i+=100;
$i-=10;
}
sleep(3);
} while( $i > 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment