class Subscriber

Properties

bool $closed
protected CommandInvoker $commandInvoker
protected array<string, true> $channels

Active prefixed channel subscriptions.

protected array<string, true> $patterns

Active prefixed pattern subscriptions.

Methods

__construct(string $host, int $port = 6379, string|array|null $password = null, float $timeout = 5.0, string $prefix = '', string|null $username = null, string|null $scheme = null, array $context = [], StdoutLoggerInterface|null $logger = null)

Create a new Redis subscriber.

void
subscribe(string ...$channels)

Subscribe to Redis channels.

void
unsubscribe(string ...$channels)

Unsubscribe from Redis channels.

void
psubscribe(string ...$channels)

Subscribe to Redis channel patterns.

void
punsubscribe(string ...$channels)

Unsubscribe from Redis channel patterns.

channel()

Get the subscriber message channel.

void
close()

Close the Redis subscriber.

string|bool
ping(float $timeout = 1)

Ping the Redis subscriber connection.

void
connect()

Connect the Redis subscriber.

Details

at line 39
__construct(string $host, int $port = 6379, string|array|null $password = null, float $timeout = 5.0, string $prefix = '', string|null $username = null, string|null $scheme = null, array $context = [], StdoutLoggerInterface|null $logger = null)

Create a new Redis subscriber.

Parameters

string $host
int $port
string|array|null $password
float $timeout
string $prefix
string|null $username
string|null $scheme
array $context
StdoutLoggerInterface|null $logger

Exceptions

SocketException
Throwable

at line 60
void subscribe(string ...$channels)

Subscribe to Redis channels.

Parameters

string ...$channels

Return Value

void

Exceptions

SocketException
Throwable
SubscribeException

at line 80
void unsubscribe(string ...$channels)

Unsubscribe from Redis channels.

Parameters

string ...$channels

Return Value

void

Exceptions

SocketException
Throwable

at line 102
void psubscribe(string ...$channels)

Subscribe to Redis channel patterns.

Parameters

string ...$channels

Return Value

void

Exceptions

SocketException
Throwable
SubscribeException

at line 122
void punsubscribe(string ...$channels)

Unsubscribe from Redis channel patterns.

Parameters

string ...$channels

Return Value

void

Exceptions

SocketException
Throwable

at line 140
Channel channel()

Get the subscriber message channel.

Return Value

Channel

at line 150
void close()

Close the Redis subscriber.

Return Value

void

Exceptions

SocketException

at line 162
string|bool ping(float $timeout = 1)

Ping the Redis subscriber connection.

Parameters

float $timeout

Return Value

string|bool

Exceptions

SocketException
Throwable

at line 173
protected void connect()

Connect the Redis subscriber.

Return Value

void

Exceptions

SocketException
Throwable