gdDocumentation0.8.0

API reference

GDRedisPool

Concurrency-safe pool distributing work across several Redis connections.

The pool serves independent commands. Use a dedicated GDRedisClient for commands that change connection state, such as SELECT, MULTI, WATCH, and subscriptions.

open() only records the target; networking starts with the first query(). A connection in use is held until it is returned, and callers wait in arrival order when none is free. Cancelling a waiter affects no other call; cancelling a running call closes its connection.

size() counts connections, including those still connecting. in_flight() counts unfinished calls, including those waiting for a connection.

Methods

open

open(host: String = "127.0.0.1", port: int = 6379, opts: Dictionary = {  }, size: int = 0) -> Variant, Err

Configure the destination without creating physical connections until the first query.

Parameters

NameTypeDefaultDescription
hostString"127.0.0.1"Hostname or IP address used for connecting or binding.
portint6379Network port number. A listening port of zero lets the OS select a port.
optsDictionary{ }Named options for this operation. Omitted entries use their documented defaults.
sizeint0Number of physical connections in the pool.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

query

query(cmd: String, args: Array = []) -> Variant, Err

Borrow a connection exclusively, waiting for return when the pool is at capacity.

Parameters

NameTypeDefaultDescription
cmdStringRequiredCommand name; argument values are passed separately.
argsArray[]Arguments in call or parameter-binding order.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

open_async

open_async(host: String = "127.0.0.1", port: int = 6379, opts: Dictionary = {  }, size: int = 0) -> await Variant, Err

Configure the destination without creating physical connections until the first query.

Parameters

NameTypeDefaultDescription
hostString"127.0.0.1"Hostname or IP address used for connecting or binding.
portint6379Network port number. A listening port of zero lets the OS select a port.
optsDictionary{ }Named options for this operation. Omitted entries use their documented defaults.
sizeint0Number of physical connections in the pool.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

query_async

query_async(cmd: String, args: Array = []) -> await Variant, Err

Borrow a connection exclusively, waiting for return when the pool is at capacity.

Parameters

NameTypeDefaultDescription
cmdStringRequiredCommand name; argument values are passed separately.
argsArray[]Arguments in call or parameter-binding order.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

close

close() -> void

Close waiters and borrowed connections first so reopening cannot inherit stale work.

Parameters

No parameters.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

size

size() -> int

Return the number of physical connections currently owned by this pool.

Parameters

No parameters.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

in_flight

in_flight() -> int

Return the number of active queries.

Parameters

No parameters.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.