PHP Class Predis\Client

Author: Daniele Alessandri ([email protected])
Inheritance: implements predis\ClientInterface
Afficher le fichier Open project: nrk/predis Class Usage Examples

Méthodes publiques

Méthode Description
__call ( $commandID, $arguments )
__construct ( mixed $parameters = null, mixed $options = null )
connect ( ) Opens the underlying connection and connects to the server.
createCommand ( $commandID, $arguments = [] )
disconnect ( ) Closes the underlying connection and disconnects from the server.
executeCommand ( Predis\Command\CommandInterface $command )
executeRaw ( array $arguments, boolean &$error = null ) : mixed Executes a command without filtering its arguments, parsing the response, applying any prefix to keys or throwing exceptions on Redis errors even regardless of client options.
getClientBy ( string $selector, string $value, callable | null $callable = null ) : predis\ClientInterface | mixed Creates a new client from the specified .
getCommandFactory ( )
getConnection ( )
getIterator ( )
getOptions ( )
isConnected ( ) : boolean Returns the current state of the underlying connection.
monitor ( ) : Consumer Creates a new monitor consumer and returns it.
pipeline ( ) : Pipeline | array Creates a new pipeline context and returns it, or returns the results of a pipeline executed inside the optionally provided callable object.
pubSubLoop ( ) : Consumer | null Creates a new publish/subscribe context and returns it, or starts its loop inside the optionally provided callable object.
quit ( ) Closes the underlying connection and disconnects from the server.
transaction ( ) : MultiExec | array Creates a new transaction context and returns it, or returns the results of a transaction executed inside the optionally provided callable object.

Méthodes protégées

Méthode Description
createAggregateConnection ( mixed $parameters, string $option ) : Closure Creates an aggregate connection.
createConnection ( mixed $parameters ) : Predis\Connection\ConnectionInterface Creates single or aggregate connections from different types of arguments (string, array) or returns the passed argument if it is an instance of a class implementing Predis\Connection\ConnectionInterface.
createOptions ( mixed $options ) : Predis\Configuration\OptionsInterface Creates a new instance of Predis\Configuration\Options from different types of arguments or simply returns the passed argument if it is an instance of Predis\Configuration\OptionsInterface.
createPipeline ( array $options = null, mixed $callable = null ) : Pipeline | array Actual pipeline context initializer method.
createPubSub ( array $options = null, mixed $callable = null ) : Consumer | null Actual publish/subscribe context initializer method.
createTransaction ( array $options = null, mixed $callable = null ) : MultiExec | array Actual transaction context initializer method.
onErrorResponse ( Predis\Command\CommandInterface $command, Predis\Response\ErrorInterface $response ) : mixed Handles -ERR responses returned by Redis.

Private Methods

Méthode Description
sharedContextFactory ( string $initializer, array $argv = null ) : mixed Executes the specified initializer method on $this by adjusting the actual invokation depending on the arity (0, 1 or 2 arguments). This is simply an utility method to create Redis contexts instances since they follow a common initialization path.

Method Details

__call() public méthode

public __call ( $commandID, $arguments )

__construct() public méthode

public __construct ( mixed $parameters = null, mixed $options = null )
$parameters mixed Connection parameters for one or more servers.
$options mixed Options to configure some behaviours of the client.

connect() public méthode

Opens the underlying connection and connects to the server.
public connect ( )

createAggregateConnection() protected méthode

Creates an aggregate connection.
protected createAggregateConnection ( mixed $parameters, string $option ) : Closure
$parameters mixed Connection parameters.
$option string Option for aggregate connections (`aggregate`, `cluster`, `replication`).
Résultat Closure

createCommand() public méthode

public createCommand ( $commandID, $arguments = [] )

createConnection() protected méthode

Accepted types for connection parameters are: - Instance of Predis\Connection\ConnectionInterface. - Instance of Predis\Connection\ParametersInterface. - Array - String - Callable
protected createConnection ( mixed $parameters ) : Predis\Connection\ConnectionInterface
$parameters mixed Connection parameters or connection instance.
Résultat Predis\Connection\ConnectionInterface

createOptions() protected méthode

Creates a new instance of Predis\Configuration\Options from different types of arguments or simply returns the passed argument if it is an instance of Predis\Configuration\OptionsInterface.
protected createOptions ( mixed $options ) : Predis\Configuration\OptionsInterface
$options mixed Client options.
Résultat Predis\Configuration\OptionsInterface

createPipeline() protected méthode

Actual pipeline context initializer method.
protected createPipeline ( array $options = null, mixed $callable = null ) : Pipeline | array
$options array Options for the context.
$callable mixed Optional callable used to execute the context.
Résultat Predis\Pipeline\Pipeline | array

createPubSub() protected méthode

Actual publish/subscribe context initializer method.
protected createPubSub ( array $options = null, mixed $callable = null ) : Consumer | null
$options array Options for the context.
$callable mixed Optional callable used to execute the context.
Résultat Predis\PubSub\Consumer | null

createTransaction() protected méthode

Actual transaction context initializer method.
protected createTransaction ( array $options = null, mixed $callable = null ) : MultiExec | array
$options array Options for the context.
$callable mixed Optional callable used to execute the context.
Résultat Predis\Transaction\MultiExec | array

disconnect() public méthode

Closes the underlying connection and disconnects from the server.
public disconnect ( )

executeCommand() public méthode

public executeCommand ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface

executeRaw() public méthode

It is possible to identify Redis error responses from normal responses using the second optional argument which is populated by reference.
public executeRaw ( array $arguments, boolean &$error = null ) : mixed
$arguments array Command arguments as defined by the command signature.
$error boolean Set to TRUE when Redis returned an error response.
Résultat mixed

getClientBy() public méthode

The new client instances inherites the same options of the original one. When no callable object is supplied, this method returns the new client. When a callable object is supplied, the new client is passed as its sole argument and its return value is returned by this method to the caller. NOTE: This method works against any kind of underlying connection object as it uses a duck-typing approach and looks for a suitable method that matches the selector type to extract the correct connection.
public getClientBy ( string $selector, string $value, callable | null $callable = null ) : predis\ClientInterface | mixed
$selector string Type of selector (`id`, `key`, `slot`, `command`)
$value string Values of selector.
$callable callable | null Optional callable object.
Résultat predis\ClientInterface | mixed

getCommandFactory() public méthode

public getCommandFactory ( )

getConnection() public méthode

public getConnection ( )

getIterator() public méthode

public getIterator ( )

getOptions() public méthode

public getOptions ( )

isConnected() public méthode

Returns the current state of the underlying connection.
public isConnected ( ) : boolean
Résultat boolean

monitor() public méthode

Creates a new monitor consumer and returns it.
public monitor ( ) : Consumer
Résultat Predis\Monitor\Consumer

onErrorResponse() protected méthode

Handles -ERR responses returned by Redis.
protected onErrorResponse ( Predis\Command\CommandInterface $command, Predis\Response\ErrorInterface $response ) : mixed
$command Predis\Command\CommandInterface Redis command that generated the error.
$response Predis\Response\ErrorInterface Instance of the error response.
Résultat mixed

pipeline() public méthode

Creates a new pipeline context and returns it, or returns the results of a pipeline executed inside the optionally provided callable object.
public pipeline ( ) : Pipeline | array
Résultat Predis\Pipeline\Pipeline | array

pubSubLoop() public méthode

Creates a new publish/subscribe context and returns it, or starts its loop inside the optionally provided callable object.
public pubSubLoop ( ) : Consumer | null
Résultat Predis\PubSub\Consumer | null

quit() public méthode

This is the same as Client::disconnect() as it does not actually send the QUIT command to Redis, but simply closes the connection.
public quit ( )

transaction() public méthode

Creates a new transaction context and returns it, or returns the results of a transaction executed inside the optionally provided callable object.
public transaction ( ) : MultiExec | array
Résultat Predis\Transaction\MultiExec | array