mirror of
https://github.com/predis/predis.git
synced 2026-08-23 11:43:16 +00:00
dc14c29676
Now we follow a Symfony2-like naming convention for namespaces, interfaces and classes sticking with one clear rule. - Renamed namespaces: - Predis\Network - Predis\Profiles - Predis\Iterators - Predis\Options - Predis\Commands - Predis\Commands\Processors - Renamed interfaces: - Predis\IReplyObject - Predis\IRedisServerError - Predis\IConnectionFactory - Predis\IConnectionParameters - Predis\Options\IOption - Predis\Options\IClientOptions - Predis\Profile\IServerProfile - Predis\Pipeline\IPipelineExecutor - Predis\Distribution\INodeKeyGenerator - Predis\Distribution\IDistributionStrategy - Predis\Protocol\IProtocolProcessor - Predis\Protocol\IResponseReader - Predis\Protocol\IResponseHandler - Predis\Protocol\ICommandSerializer - Predis\Protocol\IComposableProtocolProcessor - Predis\Network\IConnection - Predis\Network\IConnectionSingle - Predis\Network\IConnectionComposable - Predis\Network\IConnectionCluster - Predis\Network\IConnectionReplication - Predis\Commands\ICommand - Predis\Commands\IPrefixable - Predis\Command\Processor\ICommandProcessor - Predis\Command\Processor\ICommandProcessorChain - Predis\Command\Processor\IProcessingSupport - Renamed Classes: - Predis\Commands\Command - Predis\Network\ConnectionBase - Classes moved to different namespaces: - Predis\MonitorContext Meh
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Predis package.
|
|
*
|
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Predis\Command;
|
|
|
|
/**
|
|
* Base class used to implement an higher level abstraction for "virtual"
|
|
* commands based on EVAL.
|
|
*
|
|
* @link http://redis.io/commands/eval
|
|
* @author Daniele Alessandri <suppakilla@gmail.com>
|
|
*/
|
|
abstract class ScriptedCommand extends ServerEval
|
|
{
|
|
/**
|
|
* Gets the body of a Lua script.
|
|
*
|
|
* @return string
|
|
*/
|
|
public abstract function getScript();
|
|
|
|
/**
|
|
* Specifies the number of arguments that should be considered as keys.
|
|
*
|
|
* The default behaviour for the base class is to return FALSE to indicate that
|
|
* all the elements of the arguments array should be considered as keys, but
|
|
* subclasses can enforce a static number of keys.
|
|
*
|
|
* @todo How about returning 1 by default to make scripted commands act like
|
|
* variadic ones where the first argument is the key (KEYS[1]) and the
|
|
* rest are values (ARGV)?
|
|
*
|
|
* @return int|Boolean
|
|
*/
|
|
protected function getKeysCount()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Returns the elements from the arguments that are identified as keys.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getKeys()
|
|
{
|
|
return array_slice($this->getArguments(), 2, $this->getKeysCount());
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function filterArguments(Array $arguments)
|
|
{
|
|
$header = array($this->getScript(), ($keys = $this->getKeysCount()) !== false ? $keys : count($arguments));
|
|
|
|
return array_merge($header, $arguments);
|
|
}
|
|
}
|