class Connection

Redis connection.

Properties

protected resource $connection Socket connection.
protected bool $isPersistent Is the socket persistent?
protected int $timeout Timeout.
protected string|null $name Connection name.

Methods

__construct(string $host, int $port = 6379, bool $persistent = false, int $timeout = 60, string $name = null)

Constructor.

__destruct()

Destructor.

resource
createConnection(string $host, int $port, bool $persistent, int $timeout)

Creates a socket connection to the server.

bool
isPersistent()

Is the connection persistent?

int
getTimeout()

Returns the timeout value of the connection.

string|null
getName()

Returns the connection name.

string
appendReadErrorReason(string $message)

Appends the read error reason to the error message if possible.

string
readLine()

Gets line from the server.

string
read(int $bytes)

Reads n bytes from the server.

int
write(string $data)

Writes data to the server.

Details

at line 71
__construct(string $host, int $port = 6379, bool $persistent = false, int $timeout = 60, string $name = null)

Constructor.

Parameters

string $host Redis host
int $port Redis port
bool $persistent Should the connection be persistent?
int $timeout Timeout in seconds
string $name Connection name

at line 92
__destruct()

Destructor.

at line 109
protected resource createConnection(string $host, int $port, bool $persistent, int $timeout)

Creates a socket connection to the server.

Parameters

string $host Redis host
int $port Redis port
bool $persistent Should the connection be persistent?
int $timeout Timeout in seconds

Return Value

resource

at line 133
bool isPersistent()

Is the connection persistent?

Return Value

bool

at line 143
int getTimeout()

Returns the timeout value of the connection.

Return Value

int

at line 153
string|null getName()

Returns the connection name.

Return Value

string|null

at line 164
protected string appendReadErrorReason(string $message)

Appends the read error reason to the error message if possible.

Parameters

string $message Error message

Return Value

string

at line 179
string readLine()

Gets line from the server.

Return Value

string

at line 197
string read(int $bytes)

Reads n bytes from the server.

Parameters

int $bytes Number of bytes to read

Return Value

string

at line 227
int write(string $data)

Writes data to the server.

Parameters

string $data Data to write

Return Value

int