RedisPool
class RedisPool extends ConnectionPool
Properties
| protected Connection> | $channel | from ConnectionPool | |
| protected PoolOptions | $options | from ConnectionPool | |
| protected array<int, true> | $managedConnections | from ConnectionPool | |
| protected array<int, true> | $borrowedConnections | from ConnectionPool | |
| protected int | $creatingCount | from ConnectionPool | |
| protected bool | $closed | from ConnectionPool | |
| protected UsageTracker|null | $usageTracker | from ConnectionPool | |
| protected bool | $usageTrackerInitialized | from ConnectionPool | |
| protected IdleConnectionMonitor|null | $idleMonitor | from ConnectionPool | |
| protected array | $config | ||
| protected Timer|null | $heartbeatTimer | ||
| protected int|null | $heartbeatTimerId | ||
| protected bool | $heartbeatStarted |
Methods
Enable background maintenance after pool initialization succeeds.
Check one idle connection and discard it when unhealthy.
Close the Redis pool and clear its shared resources.
Get the current number of connections managed by the pool.
Get the number of connections currently available in the pool.
Create a usage policy for this Redis pool.
Create a new pooled Redis connection.
Return an idle connection without changing its activity timestamps.
Convert seconds to nanoseconds without overflowing integer arithmetic.
Build a monotonic deadline without overflowing at long durations or uptimes.
Ensure that a connection belongs to this pool before destroying it.
Get the Redis connection configuration.
Start the heartbeat timer if configured.
Clear the heartbeat timer.
Run one heartbeat sweep over currently idle connections.
Details
at line 33
__construct(Container $container, string $name)
Create a new Redis pool instance.
in
ConnectionPool at line 60
string
getName()
Get the pool name.
at line 51
void
start()
Enable background maintenance after pool initialization succeeds.
in
ConnectionPool at line 84
Connection
borrow()
Borrow a connection from the pool.
in
ConnectionPool at line 126
void
release(Connection $connection)
Release a connection back to the pool.
in
ConnectionPool at line 143
void
discard(Connection $connection)
Discard a borrowed connection from the pool.
in
ConnectionPool at line 154
void
trimExcessIdle()
Close excess idle connections without checking their age.
Stop when the managed count reaches the retained minimum or no idle connections remain.
in
ConnectionPool at line 169
void
checkIdleConnection()
Check one idle connection and discard it when unhealthy.
at line 88
void
close()
Close the Redis pool and clear its shared resources.
in
ConnectionPool at line 243
bool
isClosed()
Determine if the pool is closed.
in
ConnectionPool at line 251
int
getManagedCount()
Get the current number of connections managed by the pool.
in
ConnectionPool at line 259
int
getBorrowedCount()
Return the number of connections borrowed by callers.
in
ConnectionPool at line 267
PoolOptions
getOptions()
Get the pool configuration options.
in
ConnectionPool at line 275
int
getIdleCount()
Get the number of connections currently available in the pool.
in
ConnectionPool at line 283
int
getWaitingCount()
Get the number of coroutines waiting for a connection.
in
ConnectionPool at line 293
array
getStats()
Return the pool's current resource counts and closed state.
at line 68
protected UsageTracker|null
createUsageTracker()
Create a usage policy for this Redis pool.
at line 76
protected Connection
createConnection()
Create a new pooled Redis connection.
in
ConnectionPool at line 323
protected Connection|false
popIdleConnection()
Pop and validate one idle connection.
in
ConnectionPool at line 347
protected void
requeueConnection(Connection $connection)
Return an idle connection without changing its activity timestamps.
in
ConnectionPool at line 365
protected void
destroyConnection(Connection $connection)
Destroy a managed connection and release its capacity.
in
ConnectionPool at line 387
protected void
report(Throwable|string $error)
Report a pool maintenance or cleanup failure without throwing.
in
ConnectionPool at line 398
protected StdoutLoggerInterface|null
getLogger()
Get the logger instance if available.
in
ConnectionPool at line 485
protected int
nanoseconds(float $seconds)
Convert seconds to nanoseconds without overflowing integer arithmetic.
in
ConnectionPool at line 495
protected int
deadline(float $seconds)
Build a monotonic deadline without overflowing at long durations or uptimes.
in
ConnectionPool at line 508
protected int
ensureManaged(Connection $connection)
Ensure that a connection belongs to this pool before destroying it.
at line 60
array
getConfig()
Get the Redis connection configuration.
at line 102
protected void
startHeartbeat()
Start the heartbeat timer if configured.
at line 145
protected void
clearHeartbeat()
Clear the heartbeat timer.
at line 159
protected void
heartbeat()
Run one heartbeat sweep over currently idle connections.
at line 178
protected void
heartbeatConnection(RedisConnection $connection)
Heartbeat one idle connection.
at line 211
protected void
discardHeartbeatConnection(RedisConnection $connection)
Discard an idle connection from the pool.