gdDocumentation0.8.0

API reference

GDRedisClient

Client for one Redis connection. Regular methods suspend only their caller; *_async returns Signals for concurrent composition.

Methods

open

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

Connect and immediately authenticate when a password is supplied. Return a signal whose completion carries a value and an Err.

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.

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

Send one command and read one reply; additional commands may queue without waiting.

Return a command value and Err. A missing value is NOT_FOUND with info.code=nil; null elements within array replies remain null. Binary bulk values remain PackedByteArray.

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.

A WATCH abort returns Err.INTERRUPTED with e.info.code == "tx_failed". The size of one send follows the server's limits.

pipeline

pipeline(cmds: Array) -> Array, Err

Send a pipeline and collect replies as an array in one round trip. Each command has the form ["SET", "k", "v"].

Always return an Array in command order, including one-command pipelines. Failure retains known replies and marks unknown replies with Err.

Parameters

NameTypeDefaultDescription
cmdsArrayRequiredCommands in execution order, each represented by its command and argument values.

Return value

Array, 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.

transaction

transaction(cmds: Array) -> Array, Err

Wrap commands in MULTI and EXEC for transactional execution.

Return command results and Err. WATCH abort is INTERRUPTED with info.code=tx_failed; command failures retain sibling results.

Parameters

NameTypeDefaultDescription
cmdsArrayRequiredCommands in execution order, each represented by its command and argument values.

Return value

Array, 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.

subscribe

subscribe(channels: PackedStringArray) -> Variant, Err

Begin subscription reads and emit message for each received item.

Parameters

NameTypeDefaultDescription
channelsPackedStringArrayRequiredChannel names to subscribe to.

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 = {  }) -> await Variant, Err

Connect and immediately authenticate when a password is supplied. Return a signal whose completion carries a value and an Err.

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.

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

Send one command and read one reply; additional commands may queue without waiting.

Return a command value and Err. A missing value is NOT_FOUND with info.code=nil; null elements within array replies remain null. Binary bulk values remain PackedByteArray.

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.

A WATCH abort returns Err.INTERRUPTED with e.info.code == "tx_failed". The size of one send follows the server's limits.

pipeline_async

pipeline_async(cmds: Array) -> await Array, Err

Send a pipeline and collect replies as an array in one round trip. Each command has the form ["SET", "k", "v"].

Parameters

NameTypeDefaultDescription
cmdsArrayRequiredCommands in execution order, each represented by its command and argument values.

Return value

await Array, 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.

transaction_async

transaction_async(cmds: Array) -> await Array, Err

Wrap commands in MULTI and EXEC for transactional execution.

Parameters

NameTypeDefaultDescription
cmdsArrayRequiredCommands in execution order, each represented by its command and argument values.

Return value

await Array, 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.

subscribe_async

subscribe_async(channels: PackedStringArray) -> await Variant, Err

Begin subscription reads and emit message for each received item.

Parameters

NameTypeDefaultDescription
channelsPackedStringArrayRequiredChannel names to subscribe to.

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.

is_open

is_open() -> bool

---------------- Connections ----------------

Parameters

No parameters.

Return value

bool

Errors

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

is_subscribed

is_subscribed() -> bool

Return whether this connection is in subscription mode.

Parameters

No parameters.

Return value

bool

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

Count commands queued for encoding or awaiting server replies.

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.

close

close() -> void

Close and release retained resources.

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.