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|null $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|null $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|null $name Connection name

at line 92
__destruct()

Destructor.

at line 110
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

Exceptions

RedisException

at line 134
bool isPersistent()

Is the connection persistent?

Return Value

bool

at line 144
int getTimeout()

Returns the timeout value of the connection.

Return Value

int

at line 154
string|null getName()

Returns the connection name.

Return Value

string|null

at line 165
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 181
string readLine()

Gets line from the server.

Return Value

string

Exceptions

RedisException

at line 200
string read(int $bytes)

Reads n bytes from the server.

Parameters

int $bytes Number of bytes to read

Return Value

string

Exceptions

RedisException

at line 231
int write(string $data)

Writes data to the server.

Parameters

string $data Data to write

Return Value

int

Exceptions

RedisException