简短的回答不,你不能执行。让我解释一下;
public function createCommand($commandID, array $arguments = array())
{
$commandID = strtoupper($commandID);
if (!isset($this->commands[$commandID])) {
throw new ClientException("Command '$commandID' is not a registered Redis command.");
}
$commandClass = $this->commands[$commandID];
$command = new $commandClass();
$command->setArguments($arguments);
if (isset($this->processor)) {
$this->processor->process($command);
}
return $command;
}
当你调用方法时使用这个方法,它使用这个抽象方法来决定你是否可以调用一个方法。
abstract protected function getSupportedCommands();
getSupportedCommands 方法如下所示;
public function getSupportedCommands()
{
return array(
/* ---------------- Redis 1.2 ---------------- */
/* commands operating on the key space */
'EXISTS' => 'Predis\Command\KeyExists',
'DEL' => 'Predis\Command\KeyDelete',
'TYPE' => 'Predis\Command\KeyType',
'KEYS' => 'Predis\Command\KeyKeys',
'RANDOMKEY' => 'Predis\Command\KeyRandom',
'RENAME' => 'Predis\Command\KeyRename',
'RENAMENX' => 'Predis\Command\KeyRenamePreserve',
'EXPIRE' => 'Predis\Command\KeyExpire',
'EXPIREAT' => 'Predis\Command\KeyExpireAt',
'TTL' => 'Predis\Command\KeyTimeToLive',
'MOVE' => 'Predis\Command\KeyMove',
'SORT' => 'Predis\Command\KeySort',
'DUMP' => 'Predis\Command\KeyDump',
'RESTORE' => 'Predis\Command\KeyRestore',
....
...
..
memory usage 命令在此方法中不可用。您可以检查/vendor/predis/predis/src/Profile/RedisVersion300.php 或Profile 文件夹中的任何其他类 - 它没有在其中定义。
原因是 memory usage 方法自 Redis 版本 4.0.0 起可用。这个包在 Redis 版本 3.0.0 之前支持命令,这可以从 RedisVersion240、RedisVersion300 等类名中看出。