New command: CLIENT (Redis v2.4-dev).

This commit is contained in:
Daniele Alessandri
2011-04-24 09:32:47 +02:00
parent 819f3ca6ed
commit dd3faa3d53
3 changed files with 40 additions and 1 deletions
+2 -1
View File
@@ -15,4 +15,5 @@
as it does not cover all of its features.
* Missing tests for commands:
PUBLISH, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, DEBUG, OBJECT
PUBLISH, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, DEBUG, OBJECT,
CLIENT
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace Predis\Commands;
class Client extends Command {
public function getId() {
return 'CLIENT';
}
protected function canBeHashed() {
return false;
}
public function parseResponse($data) {
$args = array_change_key_case($this->getArguments(), CASE_UPPER);
switch (strtoupper($args[0])) {
case 'LIST':
return $this->parseClientList($data);
case 'KILL':
default:
return $data;
}
}
protected function parseClientList($data) {
$clients = array();
foreach (explode("\n", $data, -1) as $clientData) {
$client = array();
foreach (explode(' ', $clientData) as $kv) {
@list($k, $v) = explode('=', $kv);
$client[$k] = $v;
}
$clients[] = $client;
}
return $clients;
}
}
@@ -19,6 +19,7 @@ class ServerVersionNext extends ServerVersion22 {
/* remote server control commands */
'info' => '\Predis\Commands\InfoV24x',
'client' => '\Predis\Commands\Client',
));
}
}