CompositeStreamConnection
extends StreamConnection
in package
implements
CompositeConnectionInterface
Connection abstraction to Redis servers based on PHP's stream that uses an external protocol processor defining the protocol used for the communication.
Tags
Interfaces, Classes and Traits
- CompositeConnectionInterface
- Defines a connection to communicate with a single Redis server that leverages an external protocol processor to handle pluggable protocol handlers.
Table of Contents
- $initCommands : mixed
- $parameters : mixed
- $protocol : mixed
- $cachedId : mixed
- $resource : mixed
- __construct() : mixed
- __destruct() : mixed
- Disconnects from the server and destroys the underlying resource when PHP's garbage collector kicks in.
- __sleep() : mixed
- {@inheritdoc}
- __toString() : string
- Returns a string representation of the connection.
- addConnectCommand() : mixed
- Pushes the given command into a queue of commands executed when establishing the actual connection to Redis.
- connect() : mixed
- {@inheritdoc}
- disconnect() : mixed
- {@inheritdoc}
- executeCommand() : mixed
- {@inheritdoc}
- getParameters() : ParametersInterface
- Returns the parameters used to initialize the connection.
- getProtocol() : mixed
- Returns the protocol processor used by the connection.
- getResource() : mixed
- Returns the underlying resource used to communicate with Redis.
- isConnected() : mixed
- {@inheritdoc}
- read() : mixed
- {@inheritdoc}
- readBuffer() : string
- Reads the given number of bytes from the connection.
- readLine() : mixed
- Reads a line from the connection.
- readResponse() : mixed
- {@inheritdoc}
- writeBuffer() : mixed
- Writes the buffer containing over the connection.
- writeRequest() : mixed
- {@inheritdoc}
- assertParameters() : ParametersInterface
- Checks some of the parameters used to initialize the connection.
- assertSslSupport() : mixed
- Checks needed conditions for SSL-encrypted connections.
- createResource() : mixed
- Creates the underlying resource used to communicate with Redis.
- createStreamSocket() : resource
- Creates a connected stream socket resource.
- getIdentifier() : string
- Gets an identifier for the connection.
- onConnectionError() : mixed
- Helper method to handle connection errors.
- onProtocolError() : mixed
- Helper method to handle protocol errors.
- tcpStreamInitializer() : resource
- Initializes a TCP stream resource.
- tlsStreamInitializer() : resource
- Initializes a SSL-encrypted TCP stream resource.
- unixStreamInitializer() : resource
- Initializes a UNIX stream resource.
- write() : mixed
- Performs a write operation over the stream of the buffer containing a command serialized with the Redis wire protocol.
- createExceptionMessage() : string
- Helper method that returns an exception message augmented with useful details from the connection parameters.
Properties
$initCommands
protected
mixed
$initCommands
= array()
$parameters
protected
mixed
$parameters
$protocol
protected
mixed
$protocol
$cachedId
private
mixed
$cachedId
$resource
private
mixed
$resource
Methods
__construct()
public
__construct(ParametersInterface $parameters[, ProtocolProcessorInterface $protocol = null ]) : mixed
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
- $protocol : ProtocolProcessorInterface = null
-
Protocol processor.
Return values
mixed —__destruct()
Disconnects from the server and destroys the underlying resource when PHP's garbage collector kicks in.
public
__destruct() : mixed
Return values
mixed —__sleep()
{@inheritdoc}
public
__sleep() : mixed
Return values
mixed —__toString()
Returns a string representation of the connection.
public
__toString() : string
Return values
string —addConnectCommand()
Pushes the given command into a queue of commands executed when establishing the actual connection to Redis.
public
addConnectCommand(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
-
Instance of a Redis command.
Return values
mixed —connect()
{@inheritdoc}
public
connect() : mixed
Return values
mixed —disconnect()
{@inheritdoc}
public
disconnect() : mixed
Return values
mixed —executeCommand()
{@inheritdoc}
public
executeCommand(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
Return values
mixed —getParameters()
Returns the parameters used to initialize the connection.
public
getParameters() : ParametersInterface
Return values
ParametersInterface —getProtocol()
Returns the protocol processor used by the connection.
public
getProtocol() : mixed
Return values
mixed —getResource()
Returns the underlying resource used to communicate with Redis.
public
getResource() : mixed
Return values
mixed —isConnected()
{@inheritdoc}
public
isConnected() : mixed
Return values
mixed —read()
{@inheritdoc}
public
read() : mixed
Return values
mixed —readBuffer()
Reads the given number of bytes from the connection.
public
readBuffer(mixed $length) : string
Parameters
- $length : mixed
Return values
string —readLine()
Reads a line from the connection.
public
readLine() : mixed
Return values
mixed —readResponse()
{@inheritdoc}
public
readResponse(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
Return values
mixed —writeBuffer()
Writes the buffer containing over the connection.
public
writeBuffer(mixed $buffer) : mixed
Parameters
- $buffer : mixed
-
String buffer to be sent over the connection.
Return values
mixed —writeRequest()
{@inheritdoc}
public
writeRequest(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
Return values
mixed —assertParameters()
Checks some of the parameters used to initialize the connection.
protected
abstract assertParameters(ParametersInterface $parameters) : ParametersInterface
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
Tags
Return values
ParametersInterface —assertSslSupport()
Checks needed conditions for SSL-encrypted connections.
protected
assertSslSupport(ParametersInterface $parameters) : mixed
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
Tags
Return values
mixed —createResource()
Creates the underlying resource used to communicate with Redis.
protected
abstract createResource() : mixed
Return values
mixed —createStreamSocket()
Creates a connected stream socket resource.
protected
createStreamSocket(ParametersInterface $parameters, string $address, int $flags) : resource
Parameters
- $parameters : ParametersInterface
-
Connection parameters.
- $address : string
-
Address for stream_socket_client().
- $flags : int
-
Flags for stream_socket_client().
Return values
resource —getIdentifier()
Gets an identifier for the connection.
protected
getIdentifier() : string
Return values
string —onConnectionError()
Helper method to handle connection errors.
protected
onConnectionError(string $message[, int $code = null ]) : mixed
Parameters
- $message : string
-
Error message.
- $code : int = null
-
Error code.
Return values
mixed —onProtocolError()
Helper method to handle protocol errors.
protected
onProtocolError(string $message) : mixed
Parameters
- $message : string
-
Error message.
Return values
mixed —tcpStreamInitializer()
Initializes a TCP stream resource.
protected
tcpStreamInitializer(ParametersInterface $parameters) : resource
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
Return values
resource —tlsStreamInitializer()
Initializes a SSL-encrypted TCP stream resource.
protected
tlsStreamInitializer(ParametersInterface $parameters) : resource
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
Return values
resource —unixStreamInitializer()
Initializes a UNIX stream resource.
protected
unixStreamInitializer(ParametersInterface $parameters) : resource
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
Return values
resource —write()
Performs a write operation over the stream of the buffer containing a command serialized with the Redis wire protocol.
protected
write(string $buffer) : mixed
Parameters
- $buffer : string
-
Representation of a command in the Redis wire protocol.
Return values
mixed —createExceptionMessage()
Helper method that returns an exception message augmented with useful details from the connection parameters.
private
createExceptionMessage(string $message) : string
Parameters
- $message : string
-
Error message.