mirror of
https://github.com/predis/predis.git
synced 2026-09-11 02:46:59 +00:00
Parse allocation_stats if present in the INFO reply.
This commit is contained in:
@@ -11,6 +11,10 @@ class Info extends Command {
|
||||
foreach ($infoLines as $row) {
|
||||
list($k, $v) = explode(':', $row);
|
||||
if (!preg_match('/^db\d+$/', $k)) {
|
||||
if ($k === 'allocation_stats') {
|
||||
$info[$k] = $this->parseAllocationStats($v);
|
||||
continue;
|
||||
}
|
||||
$info[$k] = $v;
|
||||
}
|
||||
else {
|
||||
@@ -24,4 +28,17 @@ class Info extends Command {
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
protected function parseAllocationStats($str) {
|
||||
$stats = array();
|
||||
foreach (explode(',', $str) as $kv) {
|
||||
list($size, $objects, $extra) = explode('=', $kv);
|
||||
// hack to prevent incorrect values when parsing the >=256 key
|
||||
if (isset($extra)) {
|
||||
$size = ">=$objects";
|
||||
$objects = $extra;
|
||||
}
|
||||
$stats[$size] = $objects;
|
||||
}
|
||||
return $stats;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Predis\Commands;
|
||||
|
||||
class InfoV24x extends Command {
|
||||
class InfoV24x extends Info {
|
||||
public function canBeHashed() { return false; }
|
||||
public function getId() { return 'INFO'; }
|
||||
public function parseResponse($data) {
|
||||
@@ -20,6 +20,10 @@ class InfoV24x extends Command {
|
||||
}
|
||||
list($k, $v) = explode(':', $row);
|
||||
if (!preg_match('/^db\d+$/', $k)) {
|
||||
if ($k === 'allocation_stats') {
|
||||
$current[$k] = $this->parseAllocationStats($v);
|
||||
continue;
|
||||
}
|
||||
$current[$k] = $v;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user