ValkeyPool class
Manages a pool of ValkeyClient connections with robust resource tracking.
This is the recommended class for high-concurrency applications as it avoids the overhead of creating new connections for every request.
v1.7.0 Features:
- Smart Release: Automatically discards stateful (dirty) connections.
- Idempotency: Safe to call release/discard multiple times.
- Leak Prevention: Tracks all created connections to prevent leaks.
Constructors
- ValkeyPool({required ValkeyConnectionSettings connectionSettings, int maxConnections = 10})
- Creates a new connection pool.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- idleConnectionCount → int
-
Returns the number of connections currently idle.
no setter
- leasedConnectionCount → int
-
Returns the number of connections currently in use.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- totalConnectionCount → int
-
Returns the total number of connections managed by this pool.
no setter
Methods
-
acquire(
) → Future< ValkeyClient> - Acquires a client connection from the pool.
-
close(
) → Future< void> - Closes all connections and the pool itself.
-
discard(
ValkeyClient client) → Future< void> - Explicitly discards a connection, removing it from the pool and closing it.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
release(
ValkeyClient client) → void - Releases a connection back to the pool. Automatically discards if the client is closed or stateful (Smart Release).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited