1

img-save.pl:

* fix download condition
* when getting memcached keys we use  only first  slab in list, now all slabs
  are used, so we get full list of keys
This commit is contained in:
eleksir
2018-03-17 23:27:38 +03:00
parent 6fccf86181
commit 2105442db7

View File

@@ -4,6 +4,7 @@ use warnings "all";
use strict;
use Cache::Memcached;
use URI::URL;
use Data::Dumper;
my $HTINY = undef;
my $HTINYS = undef;
@@ -69,32 +70,40 @@ while ( 1 ) {
if (defined($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'})
and (length($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}) > 2)) {
my $slabinfo = (split("\n", $itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}))[0];
my $slab = (split(/\:/, $slabinfo))[1];
my $itemsamount = (split(/ /, $slabinfo))[2];
my $cachedump = $memd->stats(["cachedump $slab $itemsamount"]);
foreach my $stat (split("\n", $itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'})) {
my $slab;
my $itemsamount;
if ($stat =~ /^STAT items\:(\d+)\:number (\d+)/) {
$slab = $1;
$itemsamount = $2;
} else {
undef $slab;
undef $itemsamount;
next;
}
my $cachedump = $memd->stats(["cachedump $slab $itemsamount"]);
my @keys = map {
(split(/ /))[1];
} split(/\n/, $cachedump->{'hosts'}->{'127.0.0.1:11211'}->{"cachedump $slab $itemsamount"});
foreach my $key (@keys) {
next unless ($key =~ /^irssi_/);
next unless ($key =~ /^xchtlink_/);
if (($key =~ /^irssi_/) or ($key =~ /^xchtlink_/)) {
my $url = $memd->get($key);
cdlfunc($url);
undef $url;
$memd->delete($key);
}
}
undef $slabinfo;
undef $slab;
undef $itemsamount;
undef $cachedump;
@keys = -1;
undef @keys;
}
}
undef $itemref;
$memd->disconnect_all;