class Redis

Redis client.

Based on the protocol specification at http://redis.io/topics/protocol.

Constants

CRLF

Command terminator.

CRLF_LENGTH

Command terminator length.

Properties

protected string $password Redis password.
protected int $database Redis database.
protected bool $pipelined Is pipelining enabled?
protected array $commands Pipelined commands.
protected Connection $connection Redis connection.
protected array $clusterClients Cluster clients.
protected string $lastCommand Last command.

Methods

__construct(Connection $connection, array $options = [])

Constructor.

getConnection()

Returns the connection.

array
getClusterClients()

Returns the cluster clients.

createClusterClient(string $server)

Creates a cluster client.

getClusterClient(string $serverInfo)

Gets a cluster client.

mixed
handleErrorResponse(string $response)

Handles redis error responses.

string
handleStatusResponse(string $response)

Handles a status response.

int
handleIntegerResponse(string $response)

Handles a integer response.

string|null
handleBulkResponse(string $response)

Handles a bulk response.

array|null
handleMultiBulkResponse(string $response)

Handles a multi-bulk response.

mixed
getResponse()

Returns response from redis server.

sendCommandToServer(string $command)

Sends command to server.

array
pipeline(Closure $pipeline)

Pipeline commands.

mixed
sendCommandAndGetResponse(string $command)

Executes raw Redis commands and returns the response.

array
buildCommand(string $name)

Builds command from method name.

mixed
__call(string $name, array $arguments)

Sends command to Redis server and returns response.

Details

at line 103
__construct(Connection $connection, array $options = [])

Constructor.

Parameters

Connection $connection Redis connection
array $options Options

at line 123
Connection getConnection()

Returns the connection.

Return Value

Connection

at line 133
array getClusterClients()

Returns the cluster clients.

Return Value

array

at line 144
protected Redis createClusterClient(string $server)

Creates a cluster client.

Parameters

string $server Server string

Return Value

Redis

at line 165
protected Redis getClusterClient(string $serverInfo)

Gets a cluster client.

Parameters

string $serverInfo Cluster slot and server string

Return Value

Redis

at line 184
protected mixed handleErrorResponse(string $response)

Handles redis error responses.

Parameters

string $response Error response

Return Value

mixed

Exceptions

RedisException

at line 207
protected string handleStatusResponse(string $response)

Handles a status response.

Parameters

string $response Redis response

Return Value

string

at line 218
protected int handleIntegerResponse(string $response)

Handles a integer response.

Parameters

string $response Redis response

Return Value

int

at line 229
protected string|null handleBulkResponse(string $response)

Handles a bulk response.

Parameters

string $response Redis response

Return Value

string|null

at line 247
protected array|null handleMultiBulkResponse(string $response)

Handles a multi-bulk response.

Parameters

string $response Redis response

Return Value

array|null

at line 272
protected mixed getResponse()

Returns response from redis server.

Return Value

mixed

Exceptions

RedisException

at line 303
protected sendCommandToServer(string $command)

Sends command to server.

Parameters

string $command Command

at line 316
array pipeline(Closure $pipeline)

Pipeline commands.

Parameters

Closure $pipeline Pipelined commands

Return Value

array

at line 356
protected mixed sendCommandAndGetResponse(string $command)

Executes raw Redis commands and returns the response.

Parameters

string $command Command

Return Value

mixed

at line 369
protected array buildCommand(string $name)

Builds command from method name.

Parameters

string $name Method name

Return Value

array

at line 395
mixed __call(string $name, array $arguments)

Sends command to Redis server and returns response.

Parameters

string $name Command name
array $arguments Command arguments

Return Value

mixed