mirror of
https://github.com/predis/predis.git
synced 2026-08-30 12:15:03 +00:00
New command: CLIENT (Redis v2.4-dev).
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user