code optimization
This commit is contained in:
parent
49e812f3d3
commit
dc73117a62
|
@ -44,18 +44,16 @@ trait TraitMemcacheCommand
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
|
|
||||||
if (preg_match("/STAT items:([\d]+):number ([\d]+)/", $line, $matches)) {
|
if (preg_match("/STAT items:([\d]+):number ([\d]+)/", $line, $matches) &&
|
||||||
|
isset($matches[1]) &&
|
||||||
|
!in_array($matches[1], $keys)) {
|
||||||
|
|
||||||
if (isset($matches[1])) {
|
|
||||||
if (!in_array($matches[1], $keys)) {
|
|
||||||
$slabs[] = $matches[1];
|
$slabs[] = $matches[1];
|
||||||
$string = $this->sendMemcacheCommand("stats cachedump " . $matches[1] . " " . $matches[2]);
|
$string = $this->sendMemcacheCommand("stats cachedump " . $matches[1] . " " . $matches[2]);
|
||||||
preg_match_all("/ITEM (.*?) /", $string, $matches);
|
preg_match_all("/ITEM (.*?) /", $string, $matches);
|
||||||
$keys = array_merge($keys, $matches[1]);
|
$keys = array_merge($keys, $matches[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $keys;
|
return $keys;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +81,7 @@ trait TraitMemcacheCommand
|
||||||
fwrite($s, $command . "\r\n");
|
fwrite($s, $command . "\r\n");
|
||||||
$buf = '';
|
$buf = '';
|
||||||
|
|
||||||
while ((!feof($s))) {
|
while (!feof($s)) {
|
||||||
|
|
||||||
$buf .= fgets($s, 256);
|
$buf .= fgets($s, 256);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue