Permalink
Browse files

[phpdoc] Add API documentation.

This is a starting point to add a documentation of the whole set of APIs and
classes of Predis. The next step will be to actually improve and extend it.
  • Loading branch information...
1 parent 1f2104e commit 4e6ed3f26d04099f81008b68a717cbd624ce5f66 @nrk committed Oct 18, 2011
Showing with 3,818 additions and 48 deletions.
  1. +16 −0 lib/Predis/Autoloader.php
  2. +175 −9 lib/Predis/Client.php
  3. +5 −0 lib/Predis/ClientException.php
  4. +42 −0 lib/Predis/ClientOptions.php
  5. +67 −0 lib/Predis/Commands/Command.php
  6. +13 −0 lib/Predis/Commands/ConnectionAuth.php
  7. +13 −0 lib/Predis/Commands/ConnectionEcho.php
  8. +16 −0 lib/Predis/Commands/ConnectionPing.php
  9. +13 −0 lib/Predis/Commands/ConnectionQuit.php
  10. +13 −0 lib/Predis/Commands/ConnectionSelect.php
  11. +13 −0 lib/Predis/Commands/HashDelete.php
  12. +10 −0 lib/Predis/Commands/HashExists.php
  13. +7 −0 lib/Predis/Commands/HashGet.php
  14. +10 −0 lib/Predis/Commands/HashGetAll.php
  15. +10 −0 lib/Predis/Commands/HashGetMultiple.php
  16. +7 −0 lib/Predis/Commands/HashIncrementBy.php
  17. +7 −0 lib/Predis/Commands/HashKeys.php
  18. +7 −0 lib/Predis/Commands/HashLength.php
  19. +12 −1 lib/Predis/Commands/HashSet.php
  20. +10 −0 lib/Predis/Commands/HashSetMultiple.php
  21. +10 −0 lib/Predis/Commands/HashSetPreserve.php
  22. +7 −0 lib/Predis/Commands/HashValues.php
  23. +42 −0 lib/Predis/Commands/ICommand.php
  24. +16 −0 lib/Predis/Commands/KeyDelete.php
  25. +10 −0 lib/Predis/Commands/KeyExists.php
  26. +10 −0 lib/Predis/Commands/KeyExpire.php
  27. +10 −0 lib/Predis/Commands/KeyExpireAt.php
  28. +10 −0 lib/Predis/Commands/KeyKeys.php
  29. +7 −0 lib/Predis/Commands/KeyKeysV12x.php
  30. +13 −0 lib/Predis/Commands/KeyMove.php
  31. +10 −0 lib/Predis/Commands/KeyPersist.php
  32. +13 −0 lib/Predis/Commands/KeyRandom.php
  33. +13 −0 lib/Predis/Commands/KeyRename.php
  34. +10 −0 lib/Predis/Commands/KeyRenamePreserve.php
  35. +13 −0 lib/Predis/Commands/KeySort.php
  36. +7 −0 lib/Predis/Commands/KeyTimeToLive.php
  37. +7 −0 lib/Predis/Commands/KeyType.php
  38. +7 −0 lib/Predis/Commands/ListIndex.php
  39. +7 −0 lib/Predis/Commands/ListInsert.php
  40. +7 −0 lib/Predis/Commands/ListLength.php
  41. +7 −0 lib/Predis/Commands/ListPopFirst.php
  42. +13 −0 lib/Predis/Commands/ListPopFirstBlocking.php
  43. +7 −0 lib/Predis/Commands/ListPopLast.php
  44. +7 −0 lib/Predis/Commands/ListPopLastBlocking.php
  45. +13 −0 lib/Predis/Commands/ListPopLastPushHead.php
  46. +13 −0 lib/Predis/Commands/ListPopLastPushHeadBlocking.php
  47. +7 −0 lib/Predis/Commands/ListPushHead.php
  48. +7 −0 lib/Predis/Commands/ListPushHeadX.php
  49. +10 −0 lib/Predis/Commands/ListPushTail.php
  50. +7 −0 lib/Predis/Commands/ListPushTailX.php
  51. +7 −0 lib/Predis/Commands/ListRange.php
  52. +7 −0 lib/Predis/Commands/ListRemove.php
  53. +7 −0 lib/Predis/Commands/ListSet.php
  54. +7 −0 lib/Predis/Commands/ListTrim.php
  55. +19 −0 lib/Predis/Commands/PrefixHelpers.php
  56. +10 −0 lib/Predis/Commands/Processors/ICommandProcessor.php
  57. +24 −2 lib/Predis/Commands/Processors/ICommandProcessorChain.php
  58. +16 −0 lib/Predis/Commands/Processors/IProcessingSupport.php
  59. +22 −0 lib/Predis/Commands/Processors/KeyPrefixProcessor.php
  60. +42 −0 lib/Predis/Commands/Processors/ProcessorChain.php
  61. +10 −0 lib/Predis/Commands/PubSubPublish.php
  62. +16 −0 lib/Predis/Commands/PubSubSubscribe.php
  63. +7 −0 lib/Predis/Commands/PubSubSubscribeByPattern.php
  64. +13 −0 lib/Predis/Commands/PubSubUnsubscribe.php
  65. +7 −0 lib/Predis/Commands/PubSubUnsubscribeByPattern.php
  66. +23 −0 lib/Predis/Commands/ScriptedCommand.php
  67. +16 −0 lib/Predis/Commands/ServerBackgroundRewriteAOF.php
  68. +16 −0 lib/Predis/Commands/ServerBackgroundSave.php
  69. +23 −0 lib/Predis/Commands/ServerClient.php
  70. +13 −0 lib/Predis/Commands/ServerConfig.php
  71. +13 −0 lib/Predis/Commands/ServerDatabaseSize.php
  72. +13 −0 lib/Predis/Commands/ServerEval.php
  73. +7 −0 lib/Predis/Commands/ServerEvalSHA.php
  74. +13 −0 lib/Predis/Commands/ServerFlushAll.php
  75. +13 −0 lib/Predis/Commands/ServerFlushDatabase.php
  76. +28 −0 lib/Predis/Commands/ServerInfo.php
  77. +7 −0 lib/Predis/Commands/ServerInfoV26x.php
  78. +13 −0 lib/Predis/Commands/ServerLastSave.php
  79. +13 −0 lib/Predis/Commands/ServerMonitor.php
  80. +13 −0 lib/Predis/Commands/ServerObject.php
  81. +13 −0 lib/Predis/Commands/ServerSave.php
  82. +13 −0 lib/Predis/Commands/ServerShutdown.php
  83. +16 −0 lib/Predis/Commands/ServerSlaveOf.php
  84. +13 −0 lib/Predis/Commands/SetAdd.php
  85. +7 −0 lib/Predis/Commands/SetCardinality.php
  86. +10 −0 lib/Predis/Commands/SetDifference.php
  87. +7 −0 lib/Predis/Commands/SetDifferenceStore.php
  88. +16 −0 lib/Predis/Commands/SetIntersection.php
  89. +16 −0 lib/Predis/Commands/SetIntersectionStore.php
  90. +10 −0 lib/Predis/Commands/SetIsMember.php
  91. +7 −0 lib/Predis/Commands/SetMembers.php
  92. +16 −0 lib/Predis/Commands/SetMove.php
  93. +7 −0 lib/Predis/Commands/SetPop.php
  94. +7 −0 lib/Predis/Commands/SetRandomMember.php
  95. +13 −0 lib/Predis/Commands/SetRemove.php
  96. +7 −0 lib/Predis/Commands/SetUnion.php
  97. +7 −0 lib/Predis/Commands/SetUnionStore.php
  98. +7 −0 lib/Predis/Commands/StringAppend.php
  99. +7 −0 lib/Predis/Commands/StringDecrement.php
  100. +7 −0 lib/Predis/Commands/StringDecrementBy.php
  101. +7 −0 lib/Predis/Commands/StringGet.php
  102. +7 −0 lib/Predis/Commands/StringGetBit.php
  103. +16 −0 lib/Predis/Commands/StringGetMultiple.php
  104. +7 −0 lib/Predis/Commands/StringGetRange.php
  105. +7 −0 lib/Predis/Commands/StringGetSet.php
  106. +7 −0 lib/Predis/Commands/StringIncrement.php
  107. +7 −0 lib/Predis/Commands/StringIncrementBy.php
  108. +7 −0 lib/Predis/Commands/StringSet.php
  109. +7 −0 lib/Predis/Commands/StringSetBit.php
  110. +7 −0 lib/Predis/Commands/StringSetExpire.php
  111. +16 −0 lib/Predis/Commands/StringSetMultiple.php
  112. +10 −0 lib/Predis/Commands/StringSetMultiplePreserve.php
  113. +10 −0 lib/Predis/Commands/StringSetPreserve.php
  114. +7 −0 lib/Predis/Commands/StringSetRange.php
  115. +7 −0 lib/Predis/Commands/StringStrlen.php
  116. +7 −0 lib/Predis/Commands/StringSubstr.php
  117. +13 −0 lib/Predis/Commands/TransactionDiscard.php
  118. +13 −0 lib/Predis/Commands/TransactionExec.php
  119. +13 −0 lib/Predis/Commands/TransactionMulti.php
  120. +16 −0 lib/Predis/Commands/TransactionUnwatch.php
  121. +19 −0 lib/Predis/Commands/TransactionWatch.php
  122. +13 −0 lib/Predis/Commands/ZSetAdd.php
  123. +7 −0 lib/Predis/Commands/ZSetCardinality.php
  124. +7 −0 lib/Predis/Commands/ZSetCount.php
  125. +7 −0 lib/Predis/Commands/ZSetIncrementBy.php
  126. +7 −0 lib/Predis/Commands/ZSetIntersectionStore.php
  127. +24 −0 lib/Predis/Commands/ZSetRange.php
  128. +13 −0 lib/Predis/Commands/ZSetRangeByScore.php
  129. +7 −0 lib/Predis/Commands/ZSetRank.php
  130. +13 −0 lib/Predis/Commands/ZSetRemove.php
  131. +7 −0 lib/Predis/Commands/ZSetRemoveRangeByRank.php
  132. +7 −0 lib/Predis/Commands/ZSetRemoveRangeByScore.php
  133. +7 −0 lib/Predis/Commands/ZSetReverseRange.php
  134. +7 −0 lib/Predis/Commands/ZSetReverseRangeByScore.php
  135. +7 −0 lib/Predis/Commands/ZSetReverseRank.php
  136. +7 −0 lib/Predis/Commands/ZSetScore.php
  137. +22 −0 lib/Predis/Commands/ZSetUnionStore.php
  138. +23 −1 lib/Predis/CommunicationException.php
  139. +37 −0 lib/Predis/ConnectionFactory.php
  140. +69 −0 lib/Predis/ConnectionParameters.php
  141. +58 −13 lib/Predis/DispatcherLoop.php
  142. +5 −0 lib/Predis/Distribution/EmptyRingException.php
  143. +72 −1 lib/Predis/Distribution/HashRing.php
  144. +24 −0 lib/Predis/Distribution/IDistributionStrategy.php
  145. +12 −0 lib/Predis/Distribution/INodeKeyGenerator.php
  146. +20 −0 lib/Predis/Distribution/KetamaPureRing.php
  147. +36 −0 lib/Predis/Helpers.php
  148. +12 −0 lib/Predis/IConnectionFactory.php
  149. +25 −0 lib/Predis/IConnectionParameters.php
  150. +17 −0 lib/Predis/IRedisServerError.php
  151. +5 −0 lib/Predis/IReplyObject.php
  152. +33 −3 lib/Predis/Iterators/MultiBulkResponse.php
  153. +27 −4 lib/Predis/Iterators/MultiBulkResponseSimple.php
  154. +15 −0 lib/Predis/Iterators/MultiBulkResponseTuple.php
  155. +51 −0 lib/Predis/MonitorContext.php
  156. +34 −0 lib/Predis/Network/ComposableStreamConnection.php
  157. +77 −0 lib/Predis/Network/ConnectionBase.php
  158. +5 −0 lib/Predis/Network/ConnectionException.php
  159. +39 −0 lib/Predis/Network/IConnection.php
  160. +25 −0 lib/Predis/Network/IConnectionCluster.php
  161. +34 −0 lib/Predis/Network/IConnectionComposable.php
  162. +36 −0 lib/Predis/Network/IConnectionSingle.php
  163. +90 −0 lib/Predis/Network/PhpiredisConnection.php
  164. +46 −0 lib/Predis/Network/PredisCluster.php
  165. +49 −0 lib/Predis/Network/StreamConnection.php
  166. +88 −0 lib/Predis/Network/WebdisConnection.php
  167. +23 −0 lib/Predis/Options/ClientCluster.php
  168. +11 −0 lib/Predis/Options/ClientConnectionFactory.php
  169. +8 −0 lib/Predis/Options/ClientPrefix.php
  170. +11 −0 lib/Predis/Options/ClientProfile.php
  171. +23 −0 lib/Predis/Options/CustomOption.php
  172. +26 −0 lib/Predis/Options/IOption.php
  173. +14 −0 lib/Predis/Options/Option.php
  174. +9 −0 lib/Predis/Pipeline/FireAndForgetExecutor.php
  175. +13 −0 lib/Predis/Pipeline/IPipelineExecutor.php
  176. +53 −4 lib/Predis/Pipeline/PipelineContext.php
  177. +10 −0 lib/Predis/Pipeline/SafeClusterExecutor.php
  178. +9 −0 lib/Predis/Pipeline/SafeExecutor.php
  179. +10 −0 lib/Predis/Pipeline/StandardExecutor.php
  180. +5 −0 lib/Predis/PredisException.php
  181. +35 −0 lib/Predis/Profiles/IServerProfile.php
  182. +73 −0 lib/Predis/Profiles/ServerProfile.php
  183. +11 −0 lib/Predis/Profiles/ServerVersion12.php
  184. +11 −0 lib/Predis/Profiles/ServerVersion20.php
  185. +11 −0 lib/Predis/Profiles/ServerVersion22.php
  186. +11 −0 lib/Predis/Profiles/ServerVersion24.php
  187. +11 −0 lib/Predis/Profiles/ServerVersionNext.php
  188. +11 −0 lib/Predis/Protocol/ICommandSerializer.php
  189. +30 −0 lib/Predis/Protocol/IComposableProtocolProcessor.php
  190. +19 −0 lib/Predis/Protocol/IProtocolProcessor.php
  191. +13 −0 lib/Predis/Protocol/IResponseHandler.php
  192. +12 −0 lib/Predis/Protocol/IResponseReader.php
  193. +6 −0 lib/Predis/Protocol/ProtocolException.php
  194. +40 −0 lib/Predis/Protocol/Text/ComposableTextProtocol.php
  195. +14 −0 lib/Predis/Protocol/Text/ResponseBulkHandler.php
  196. +13 −0 lib/Predis/Protocol/Text/ResponseErrorHandler.php
  197. +13 −0 lib/Predis/Protocol/Text/ResponseErrorSilentHandler.php
  198. +14 −0 lib/Predis/Protocol/Text/ResponseIntegerHandler.php
  199. +14 −0 lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php
  200. +14 −0 lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php
  201. +10 −0 lib/Predis/Protocol/Text/ResponseStatusHandler.php
  202. +10 −0 lib/Predis/Protocol/Text/TextCommandSerializer.php
  203. +18 −0 lib/Predis/Protocol/Text/TextProtocol.php
  204. +38 −0 lib/Predis/Protocol/Text/TextResponseReader.php
  205. +87 −0 lib/Predis/PubSubContext.php
  206. +20 −0 lib/Predis/ResponseError.php
  207. +23 −0 lib/Predis/ResponseQueued.php
  208. +15 −0 lib/Predis/ServerException.php
  209. +15 −0 lib/Predis/Transaction/AbortedMultiExecException.php
  210. +115 −10 lib/Predis/Transaction/MultiExecContext.php
@@ -11,22 +11,38 @@
namespace Predis;
+/**
+ * Implements a lightweight PSR-0 compliant autoloader.
+ *
+ * @author Eric Naeseth <eric@thumbtack.com>
+ */
class Autoloader
{
private $_baseDir;
private $_prefix;
+ /**
+ * @param string $baseDirectory Base directory where the source files are located.
+ */
public function __construct($baseDirectory = null)
{
$this->_baseDir = $baseDirectory ?: dirname(__FILE__);
$this->_prefix = __NAMESPACE__ . '\\';
}
+ /**
+ * Registers the autoloader class with the PHP SPL autoloader.
+ */
public static function register()
{
spl_autoload_register(array(new self, 'autoload'));
}
+ /**
+ * Loads a class from a file using its fully qualified name.
+ *
+ * @param string $className Fully qualified name of a class.
+ */
public function autoload($className)
{
if (0 !== strpos($className, $this->_prefix)) {
View
@@ -19,6 +19,11 @@
use Predis\Pipeline\PipelineContext;
use Predis\Transaction\MultiExecContext;
+/**
+ * Main class that exposes the most high-level interface to interact with Redis.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
class Client
{
const VERSION = '0.7.0-dev';
@@ -28,6 +33,12 @@ class Client
private $_connection;
private $_connectionFactory;
+ /**
+ * Initializes a new client with optional connection parameters and client options.
+ *
+ * @param mixed $parameters Connection parameters for one or multiple Redis servers.
+ * @param mixed $options Options that specify certain behaviours for the client.
+ */
public function __construct($parameters = null, $options = null)
{
$options = $this->filterOptions($options);
@@ -43,6 +54,14 @@ public function __construct($parameters = null, $options = null)
$this->_connection = $this->initializeConnection($parameters);
}
+ /**
+ * Creates an instance of Predis\Options\ClientOptions from various types of
+ * parameters (string, array, Predis\Profiles\ServerProfile) or returns the
+ * passed object if its an instance of Predis\Options\ClientOptions.
+ *
+ * @param mixed $options Client options.
+ * @return ClientOptions
+ */
private function filterOptions($options)
{
if ($options === null) {
@@ -64,6 +83,14 @@ private function filterOptions($options)
throw new \InvalidArgumentException("Invalid type for client options");
}
+ /**
+ * Initialize one or multiple connection (cluster) objects from various types of
+ * parameters (string, array) or returns the passed object if it implements the
+ * Predis\Network\IConnection interface.
+ *
+ * @param mixed $parameters Connection parameters or object.
+ * @return IConnection
+ */
private function initializeConnection($parameters)
{
if ($parameters === null) {
@@ -89,6 +116,12 @@ private function initializeConnection($parameters)
return $this->createConnection($parameters);
}
+ /**
+ * Create a new connection to a single Redis server using the provided parameters.
+ *
+ * @param mixed $parameters Connection parameters.
+ * @return IConnectionSingle
+ */
protected function createConnection($parameters)
{
$connection = $this->_connectionFactory->create($parameters);
@@ -107,21 +140,43 @@ protected function createConnection($parameters)
return $connection;
}
+ /**
+ * Returns the server profile used by the client.
+ *
+ * @return IServerProfile
+ */
public function getProfile()
{
return $this->_profile;
}
+ /**
+ * Returns the client options specified upon client initialization.
+ *
+ * @return ClientOptions
+ */
public function getOptions()
{
return $this->_options;
}
+ /**
+ * Returns the connection factory object used by the client.
+ *
+ * @return IConnectionFactory
+ */
public function getConnectionFactory()
{
return $this->_connectionFactory;
}
+ /**
+ * Returns a new client instance for the specified connection when the client
+ * is connected to a cluster. The new client will use the same options of the
+ * the original instance.
+ *
+ * @return Client
+ */
public function getClientFor($connectionAlias)
{
if (($connection = $this->getConnection($connectionAlias)) === null) {
@@ -131,26 +186,48 @@ public function getClientFor($connectionAlias)
return new Client($connection, $this->_options);
}
+ /**
+ * Opens the connection to Redis.
+ */
public function connect()
{
$this->_connection->connect();
}
+ /**
+ * Disconnects from Redis.
+ */
public function disconnect()
{
$this->_connection->disconnect();
}
+ /**
+ * Disconnects from Redis. This method is an alias of disconnect().
+ */
public function quit()
{
$this->disconnect();
}
+ /**
+ * Checks if the underlying connection is connected to Redis.
+ *
+ * @return Boolean True means that the connection is open.
+ * False means that the connection is closed.
+ */
public function isConnected()
{
return $this->_connection->isConnected();
}
+ /**
+ * Returns the underlying connection instance or, when connected to a cluster,
+ * one of the connection instances identified by its alias.
+ *
+ * @param string $id The alias of a connection when connected to a cluster.
+ * @return IConnection
+ */
public function getConnection($id = null)
{
if (isset($id)) {
@@ -166,22 +243,48 @@ public function getConnection($id = null)
return $this->_connection;
}
+ /**
+ * Dinamically invokes a Redis command with the specified arguments.
+ *
+ * @param string $method The name of a Redis command.
+ * @param array $arguments The arguments for the command.
+ * @return mixed
+ */
public function __call($method, $arguments)
{
$command = $this->_profile->createCommand($method, $arguments);
return $this->_connection->executeCommand($command);
}
+ /**
+ * Creates a new instance of the specified Redis command.
+ *
+ * @param string $method The name of a Redis command.
+ * @param array $arguments The arguments for the command.
+ * @return ICommand
+ */
public function createCommand($method, $arguments = array())
{
return $this->_profile->createCommand($method, $arguments);
}
+ /**
+ * Executes the specified Redis command.
+ *
+ * @param ICommand $command A Redis command.
+ * @return mixed
+ */
public function executeCommand(ICommand $command)
{
return $this->_connection->executeCommand($command);
}
+ /**
+ * Executes the specified Redis command on all the nodes of a cluster.
+ *
+ * @param ICommand $command A Redis command.
+ * @return array
+ */
public function executeCommandOnShards(ICommand $command)
{
if (Helpers::isCluster($this->_connection)) {
@@ -197,6 +300,15 @@ public function executeCommandOnShards(ICommand $command)
return array($this->_connection->executeCommand($command));
}
+ /**
+ * Call the specified initializer method on $this with 0, 1 or 2 arguments.
+ *
+ * TODO: Invert $argv and $initializer.
+ *
+ * @param array $argv Arguments for the initializer.
+ * @param string $initializer The initializer method.
+ * @return mixed
+ */
private function sharedInitializer($argv, $initializer)
{
switch (count($argv)) {
@@ -216,53 +328,107 @@ private function sharedInitializer($argv, $initializer)
}
}
+ /**
+ * Creates a new pipeline context and returns it, or returns the results of
+ * a pipeline executed inside the optionally provided callable object.
+ *
+ * @param mixed $arg,... Options for the context, a callable object, or both.
+ * @return PipelineContext|array
+ */
public function pipeline(/* arguments */)
{
return $this->sharedInitializer(func_get_args(), 'initPipeline');
}
- protected function initPipeline(Array $options = null, $pipelineBlock = null)
+ /**
+ * Pipeline context initializer.
+ *
+ * @param array $options Options for the context.
+ * @param mixed $callable Optional callable object used to execute the context.
+ * @return PipelineContext|array
+ */
+ protected function initPipeline(Array $options = null, $callable = null)
{
$pipeline = new PipelineContext($this, $options);
- return $this->pipelineExecute($pipeline, $pipelineBlock);
+ return $this->pipelineExecute($pipeline, $callable);
}
- private function pipelineExecute(PipelineContext $pipeline, $block)
+ /**
+ * Executes a pipeline context when a callable object is passed.
+ *
+ * @param array $options Options of the context initialization.
+ * @param mixed $callable Optional callable object used to execute the context.
+ * @return PipelineContext|array
+ */
+ private function pipelineExecute(PipelineContext $pipeline, $callable)
{
- return $block !== null ? $pipeline->execute($block) : $pipeline;
+ return isset($callable) ? $pipeline->execute($callable) : $pipeline;
}
+ /**
+ * Creates a new transaction context and returns it, or returns the results of
+ * a transaction executed inside the optionally provided callable object.
+ *
+ * @param mixed $arg,... Options for the context, a callable object, or both.
+ * @return MultiExecContext|array
+ */
public function multiExec(/* arguments */)
{
return $this->sharedInitializer(func_get_args(), 'initMultiExec');
}
- protected function initMultiExec(Array $options = null, $block = null)
+ /**
+ * Transaction context initializer.
+ *
+ * @param array $options Options for the context.
+ * @param mixed $callable Optional callable object used to execute the context.
+ * @return MultiExecContext|array
+ */
+ protected function initMultiExec(Array $options = null, $callable = null)
{
$transaction = new MultiExecContext($this, $options ?: array());
- return isset($block) ? $transaction->execute($block) : $transaction;
+ return isset($callable) ? $transaction->execute($callable) : $transaction;
}
+ /**
+ * Creates a new Publish / Subscribe context and returns it, or executes it
+ * inside the optionally provided callable object.
+ *
+ * @param mixed $arg,... Options for the context, a callable object, or both.
+ * @return MultiExecContext|array
+ */
public function pubSub(/* arguments */)
{
return $this->sharedInitializer(func_get_args(), 'initPubSub');
}
- protected function initPubSub(Array $options = null, $block = null)
+ /**
+ * Publish / Subscribe context initializer.
+ *
+ * @param array $options Options for the context.
+ * @param mixed $callable Optional callable object used to execute the context.
+ * @return PubSubContext
+ */
+ protected function initPubSub(Array $options = null, $callable = null)
{
$pubsub = new PubSubContext($this, $options);
- if (!isset($block)) {
+ if (!isset($callable)) {
return $pubsub;
}
foreach ($pubsub as $message) {
- if ($block($pubsub, $message) === false) {
+ if ($callable($pubsub, $message) === false) {
$pubsub->closeContext();
}
}
}
+ /**
+ * Returns a new monitor context.
+ *
+ * @return MonitorContext
+ */
public function monitor()
{
return new MonitorContext($this);
@@ -11,6 +11,11 @@
namespace Predis;
+/**
+ * Exception class that identifies client-side errors.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
class ClientException extends PredisException
{
}
Oops, something went wrong.

0 comments on commit 4e6ed3f

Please sign in to comment.