WebdisConnection
in package
implements
NodeConnectionInterface
This class implements a Predis connection that actually talks with Webdis instead of connecting directly to Redis. It relies on the cURL extension to communicate with the web server and the phpiredis extension to parse the protocol for responses returned in the http response bodies.
Some features are not yet available or they simply cannot be implemented:
- Pipelining commands.
- Publish / Subscribe.
- MULTI / EXEC transactions (not yet supported by Webdis).
The connection parameters supported by this class are:
- scheme: must be 'http'.
- host: hostname or IP address of the server.
- port: TCP port of the server.
- timeout: timeout to perform the connection (default is 5 seconds).
- user: username for authentication.
- pass: password for authentication.
Tags
Interfaces, Classes and Traits
- NodeConnectionInterface
- Defines a connection used to communicate with a single Redis node.
Table of Contents
- $parameters : mixed
- $reader : mixed
- $resource : mixed
- __construct() : mixed
- __destruct() : mixed
- Frees the underlying cURL and protocol reader resources when the garbage collector kicks in.
- __sleep() : mixed
- {@inheritdoc}
- __toString() : string
- Returns a string representation of the connection.
- __wakeup() : mixed
- {@inheritdoc}
- 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.
- getResource() : mixed
- Returns the underlying resource used to communicate with Redis.
- isConnected() : mixed
- {@inheritdoc}
- read() : mixed
- Reads a response from the server.
- readResponse() : mixed
- {@inheritdoc}
- writeRequest() : mixed
- {@inheritdoc}
- feedReader() : int
- Feeds the phpredis reader resource with the data read from the network.
- getCommandId() : string
- Checks if the specified command is supported by this connection class.
- getErrorHandler() : Closure
- Returns the handler used by the protocol reader for error responses.
- getStatusHandler() : Closure
- Returns the handler used by the protocol reader for inline responses.
- assertExtensions() : mixed
- Checks if the cURL and phpiredis extensions are loaded in PHP.
- createCurl() : resource
- Initializes cURL.
- createReader() : resource
- Initializes the phpiredis protocol reader.
- throwNotSupportedException() : mixed
- Helper method used to throw on unsupported methods.
Properties
$parameters
private
mixed
$parameters
$reader
private
mixed
$reader
$resource
private
mixed
$resource
Methods
__construct()
public
__construct(ParametersInterface $parameters) : mixed
Parameters
- $parameters : ParametersInterface
-
Initialization parameters for the connection.
Tags
Return values
mixed —__destruct()
Frees the underlying cURL and protocol reader resources when the 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 —__wakeup()
{@inheritdoc}
public
__wakeup() : mixed
Return values
mixed —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 —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()
Reads a response from the server.
public
read() : mixed
Return values
mixed —readResponse()
{@inheritdoc}
public
readResponse(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
Return values
mixed —writeRequest()
{@inheritdoc}
public
writeRequest(CommandInterface $command) : mixed
Parameters
- $command : CommandInterface
Return values
mixed —feedReader()
Feeds the phpredis reader resource with the data read from the network.
protected
feedReader(resource $resource, string $buffer) : int
Parameters
- $resource : resource
-
Reader resource.
- $buffer : string
-
Buffer of data read from a connection.
Return values
int —getCommandId()
Checks if the specified command is supported by this connection class.
protected
getCommandId(CommandInterface $command) : string
Parameters
- $command : CommandInterface
-
Command instance.
Tags
Return values
string —getErrorHandler()
Returns the handler used by the protocol reader for error responses.
protected
getErrorHandler() : Closure
Return values
Closure —getStatusHandler()
Returns the handler used by the protocol reader for inline responses.
protected
getStatusHandler() : Closure
Return values
Closure —assertExtensions()
Checks if the cURL and phpiredis extensions are loaded in PHP.
private
assertExtensions() : mixed
Return values
mixed —createCurl()
Initializes cURL.
private
createCurl() : resource
Return values
resource —createReader()
Initializes the phpiredis protocol reader.
private
createReader() : resource
Return values
resource —throwNotSupportedException()
Helper method used to throw on unsupported methods.
private
throwNotSupportedException(string $method) : mixed
Parameters
- $method : string
-
Name of the unsupported method.