class RedisManager implements Factory, Connection mixin RedisProxy

Properties

protected RedisProxy> $connections

The resolved connection proxies.

Methods

__construct(Container $app, PoolFactory $factory, RedisConfig $config, RedisSentinelFactory $sentinelFactory)

Create a new Redis manager instance.

connection(UnitEnum|string|null $name = null)

Get a Redis connection by name.

void
purge(UnitEnum|string|null $name = null)

Disconnect the given connection and remove from local cache.

array
connections()

Return all of the created connections.

void
enableEvents()

Enable Redis command events.

void
disableEvents()

Disable Redis command events.

void
releaseConnections()

Release connections retained by non-coroutine task execution.

void
discardConnections()

Discard connections retained by this manager.

void
terminateConnections(Closure $terminate)

Terminate every created connection proxy.

void
listen(Closure $callback)

Register a Redis command listener with the connection.

void
listenForFailures(Closure $callback)

Register a Redis command failure listener with the connection.

void
subscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels for messages.

void
psubscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels with wildcards.

mixed
command(string $method, array $parameters = [])

Run a command against the Redis database.

throttle(string $name)

Throttle a callback for a maximum number of executions over a given duration.

funnel(string $name)

Funnel a callback for a maximum number of simultaneous executions.

mixed
__call(string $method, array $parameters)

Pass methods onto the default Redis connection.

Details

at line 37
__construct(Container $app, PoolFactory $factory, RedisConfig $config, RedisSentinelFactory $sentinelFactory)

Create a new Redis manager instance.

Parameters

Container $app
PoolFactory $factory
RedisConfig $config
RedisSentinelFactory $sentinelFactory

at line 48
RedisProxy connection(UnitEnum|string|null $name = null)

Get a Redis connection by name.

Parameters

UnitEnum|string|null $name

Return Value

RedisProxy

at line 81
void purge(UnitEnum|string|null $name = null)

Disconnect the given connection and remove from local cache.

Discards any context-pinned connection and flushes the underlying pool so all connections are closed and re-created on next use.

Boot or tests only. Flushes the shared pool; concurrent coroutines checked out before this call may complete against the destroyed pool and other coroutines lose their cached proxy reference.

Parameters

UnitEnum|string|null $name

Return Value

void

at line 119
array connections()

Return all of the created connections.

Return Value

array

at line 130
void enableEvents()

Enable Redis command events.

Boot-only. Existing pools retain their snapshotted event configuration; calling this after pool creation can leave generations with different behavior.

Return Value

void

at line 141
void disableEvents()

Disable Redis command events.

Boot-only. Existing pools retain their snapshotted event configuration; calling this after pool creation can leave generations with different behavior.

Return Value

void

at line 153
void releaseConnections()

internal  
 

Release connections retained by non-coroutine task execution.

Return Value

void

at line 167
void discardConnections()

internal  
 

Discard connections retained by this manager.

Return Value

void

at line 181
protected void terminateConnections(Closure $terminate)

Terminate every created connection proxy.

Parameters

Closure $terminate

Return Value

void

at line 204
void listen(Closure $callback)

Register a Redis command listener with the connection.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent Redis command event.

Parameters

Closure $callback

Return Value

void

at line 217
void listenForFailures(Closure $callback)

Register a Redis command failure listener with the connection.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent Redis failure event.

Parameters

Closure $callback

Return Value

void

at line 227
void subscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels for messages.

Parameters

array|string $channels
Closure $callback

Return Value

void

at line 235
void psubscribe(array|string $channels, Closure $callback)

Subscribe to a set of given channels with wildcards.

Parameters

array|string $channels
Closure $callback

Return Value

void

at line 243
mixed command(string $method, array $parameters = [])

Run a command against the Redis database.

Parameters

string $method
array $parameters

Return Value

mixed

at line 251
DurationLimiterBuilder throttle(string $name)

Throttle a callback for a maximum number of executions over a given duration.

Parameters

string $name

Return Value

DurationLimiterBuilder

at line 259
ConcurrencyLimiterBuilder funnel(string $name)

Funnel a callback for a maximum number of simultaneous executions.

Parameters

string $name

Return Value

ConcurrencyLimiterBuilder

at line 267
mixed __call(string $method, array $parameters)

Pass methods onto the default Redis connection.

Parameters

string $method
array $parameters

Return Value

mixed