Module
Module documentation.
moduleprotocol.redis
Classes
Classes and inheritance.
classprotocol.redis::Config
@brief`Config` type.
@details`Config` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class Config {
/*
@brief `host` field.classprotocol.redis::RedisError
@brief`RedisError` type.
@details`RedisError` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class RedisError {
/*
@brief `kind` field.classprotocol.redis::RespValue
@brief`RespValue` type.
@details`RespValue` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class RespValue {
/*
@brief `kind` field.classprotocol.redis::ParseResult
@brief`ParseResult` type.
@details`ParseResult` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class ParseResult {
/*
@brief `value` field.classprotocol.redis::Reader
@brief`Reader` type.
@details`Reader` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class Reader {
/*
@brief `buf` field.Functions
Free functions and class methods.
functionprotocol.redis::Config.init
Signature
func init(self: protocol.redis.Config) -> Void func init(self: protocol.redis.Config) -> Void {
self.host = "127.0.0.1";
self.port = 6379;@briefInitializes a `Config` instance.
@detailsEstablishes the initial field state for `Config` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::Config.deinit
Signature
func deinit(self: protocol.redis.Config) -> Void func deinit(self: protocol.redis.Config) -> Void {
}
}@briefReleases fallback resources at the end of the `Config` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::RedisError.init
Signature
func init(self: protocol.redis.RedisError) -> Void func init(self: protocol.redis.RedisError) -> Void {
self.kind = protocol.redis.REDIS_ERR_NONE;
self.code = "";@briefInitializes a `RedisError` instance.
@detailsEstablishes the initial field state for `RedisError` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::RedisError.is_redirect
Signature
func is_redirect(self: protocol.redis.RedisError) -> Bool func is_redirect(self: protocol.redis.RedisError) -> Bool {
return self.kind == protocol.redis.REDIS_ERR_MOVED || self.kind == protocol.redis.REDIS_ERR_ASK;
}@briefTests whether the state satisfies the condition represented by `RedisError.is_redirect`.
@detailsExecutes the `is_redirect` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RedisError.deinit
Signature
func deinit(self: protocol.redis.RedisError) -> Void func deinit(self: protocol.redis.RedisError) -> Void {
}
}@briefReleases fallback resources at the end of the `RedisError` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::RespValue.init
Signature
func init(self: protocol.redis.RespValue) -> Void func init(self: protocol.redis.RespValue) -> Void {
self.kind = protocol.redis.RESP_NULL;
self.text = "";@briefInitializes a `RespValue` instance.
@detailsEstablishes the initial field state for `RespValue` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::RespValue.is_null
Signature
func is_null(self: protocol.redis.RespValue) -> Bool func is_null(self: protocol.redis.RespValue) -> Bool {
return self.kind == protocol.redis.RESP_NULL;
}@briefTests whether the state satisfies the condition represented by `RespValue.is_null`.
@detailsExecutes the `is_null` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.is_error
Signature
func is_error(self: protocol.redis.RespValue) -> Bool func is_error(self: protocol.redis.RespValue) -> Bool {
return self.kind == protocol.redis.RESP_ERROR || self.kind == protocol.redis.RESP_BLOB_ERROR;
}@briefTests whether the state satisfies the condition represented by `RespValue.is_error`.
@detailsExecutes the `is_error` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.as_string
Signature
func as_string(self: protocol.redis.RespValue) -> String, ErrCode func as_string(self: protocol.redis.RespValue) -> String, ErrCode {
if self.kind == protocol.redis.RESP_SIMPLE_STRING || self.kind == protocol.redis.RESP_BULK_STRING || self.kind == protocol.redis.RESP_VERBATIM_STRING || self.kind == protocol.redis.RESP_BIG_NUMBER {
return self.text, std.OK;@briefProvides the system library operation `RespValue.as_string`.
@detailsExecutes the `as_string` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `String, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.as_int
Signature
func as_int(self: protocol.redis.RespValue) -> Int, ErrCode func as_int(self: protocol.redis.RespValue) -> Int, ErrCode {
if self.kind == protocol.redis.RESP_INTEGER {
return self.int_value, std.OK;@briefProvides the system library operation `RespValue.as_int`.
@detailsExecutes the `as_int` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.as_bool
Signature
func as_bool(self: protocol.redis.RespValue) -> Bool, ErrCode func as_bool(self: protocol.redis.RespValue) -> Bool, ErrCode {
if self.kind == protocol.redis.RESP_BOOL {
return self.bool_value, std.OK;@briefProvides the system library operation `RespValue.as_bool`.
@detailsExecutes the `as_bool` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `Bool, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.is_array
Signature
func is_array(self: protocol.redis.RespValue) -> Bool func is_array(self: protocol.redis.RespValue) -> Bool {
return self.kind == protocol.redis.RESP_ARRAY;
}@briefTests whether the state satisfies the condition represented by `RespValue.is_array`.
@detailsExecutes the `is_array` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.is_map
Signature
func is_map(self: protocol.redis.RespValue) -> Bool func is_map(self: protocol.redis.RespValue) -> Bool {
return self.kind == protocol.redis.RESP_MAP;
}@briefTests whether the state satisfies the condition represented by `RespValue.is_map`.
@detailsExecutes the `is_map` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.is_set
Signature
func is_set(self: protocol.redis.RespValue) -> Bool func is_set(self: protocol.redis.RespValue) -> Bool {
return self.kind == protocol.redis.RESP_SET;
}@briefTests whether the state satisfies the condition represented by `RespValue.is_set`.
@detailsExecutes the `is_set` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.is_push
Signature
func is_push(self: protocol.redis.RespValue) -> Bool func is_push(self: protocol.redis.RespValue) -> Bool {
return self.kind == protocol.redis.RESP_PUSH;
}@briefTests whether the state satisfies the condition represented by `RespValue.is_push`.
@detailsExecutes the `is_push` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.has_attrs
Signature
func has_attrs(self: protocol.redis.RespValue) -> Bool func has_attrs(self: protocol.redis.RespValue) -> Bool {
return self.attrs.len() > 0;
}@briefTests whether the object contains the specified state or data with `RespValue.has_attrs`.
@detailsExecutes the `has_attrs` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionprotocol.redis::RespValue.array_len
Signature
func array_len(self: protocol.redis.RespValue) -> Int func array_len(self: protocol.redis.RespValue) -> Int {
return self.items.len();
}@briefProvides the system library operation `RespValue.array_len`.
@detailsExecutes the `array_len` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionprotocol.redis::RespValue.array_get
Signature
func array_get(self: protocol.redis.RespValue, idx: Int) -> protocol.redis.RespValue, ErrCode func array_get(self: protocol.redis.RespValue, idx: Int) -> protocol.redis.RespValue, ErrCode {
if self.kind != protocol.redis.RESP_ARRAY && self.kind != protocol.redis.RESP_PUSH && self.kind != protocol.redis.RESP_SET {
return new protocol.redis.RespValue(), std.ERR_INVALID;@briefProvides the system library operation `RespValue.array_get`.
@detailsExecutes the `array_get` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- idxZero-based index.
@returnReturns `protocol.redis.RespValue, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.set_len
Signature
func set_len(self: protocol.redis.RespValue) -> Int func set_len(self: protocol.redis.RespValue) -> Int {
if self.kind != protocol.redis.RESP_SET {
return 0;@briefSets state or configuration with `RespValue.set_len`.
@detailsExecutes the `set_len` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionprotocol.redis::RespValue.set_get
Signature
func set_get(self: protocol.redis.RespValue, idx: Int) -> protocol.redis.RespValue, ErrCode func set_get(self: protocol.redis.RespValue, idx: Int) -> protocol.redis.RespValue, ErrCode {
if self.kind != protocol.redis.RESP_SET {
return new protocol.redis.RespValue(), std.ERR_INVALID;@briefSets state or configuration with `RespValue.set_get`.
@detailsExecutes the `set_get` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- idxZero-based index.
@returnReturns `protocol.redis.RespValue, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.push_len
Signature
func push_len(self: protocol.redis.RespValue) -> Int func push_len(self: protocol.redis.RespValue) -> Int {
if self.kind != protocol.redis.RESP_PUSH {
return 0;@briefProvides the system library operation `RespValue.push_len`.
@detailsExecutes the `push_len` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionprotocol.redis::RespValue.push_get
Signature
func push_get(self: protocol.redis.RespValue, idx: Int) -> protocol.redis.RespValue, ErrCode func push_get(self: protocol.redis.RespValue, idx: Int) -> protocol.redis.RespValue, ErrCode {
if self.kind != protocol.redis.RESP_PUSH {
return new protocol.redis.RespValue(), std.ERR_INVALID;@briefProvides the system library operation `RespValue.push_get`.
@detailsExecutes the `push_get` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- idxZero-based index.
@returnReturns `protocol.redis.RespValue, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.map_get
Signature
func map_get(self: protocol.redis.RespValue, key: String) -> protocol.redis.RespValue, ErrCode func map_get(self: protocol.redis.RespValue, key: String) -> protocol.redis.RespValue, ErrCode {
if self.kind != protocol.redis.RESP_MAP && self.kind != protocol.redis.RESP_ATTRIBUTE {
return new protocol.redis.RespValue(), std.ERR_INVALID;@briefProvides the system library operation `RespValue.map_get`.
@detailsExecutes the `map_get` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- keyKey name.
@returnReturns `protocol.redis.RespValue, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.attr_get
Signature
func attr_get(self: protocol.redis.RespValue, key: String) -> protocol.redis.RespValue, ErrCode func attr_get(self: protocol.redis.RespValue, key: String) -> protocol.redis.RespValue, ErrCode {
loop (let i: Int = 0; i < self.attrs.len(); i += 1) {
let attr: protocol.redis.RespValue = self.attrs.get_unchecked(i);@briefProvides the system library operation `RespValue.attr_get`.
@detailsExecutes the `attr_get` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- keyKey name.
@returnReturns `protocol.redis.RespValue, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::RespValue.redis_error
Signature
func redis_error(self: protocol.redis.RespValue) -> protocol.redis.RedisError func redis_error(self: protocol.redis.RespValue) -> protocol.redis.RedisError {
if !self.is_error() {
return new protocol.redis.RedisError();@briefProvides the system library operation `RespValue.redis_error`.
@detailsExecutes the `redis_error` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `protocol.redis.RedisError`.
functionprotocol.redis::RespValue.deinit
Signature
func deinit(self: protocol.redis.RespValue) -> Void func deinit(self: protocol.redis.RespValue) -> Void {
}
}@briefReleases fallback resources at the end of the `RespValue` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::ParseResult.init
Signature
func init(self: protocol.redis.ParseResult) -> Void func init(self: protocol.redis.ParseResult) -> Void {
self.value = new protocol.redis.RespValue();
self.consumed = 0;@briefInitializes a `ParseResult` instance.
@detailsEstablishes the initial field state for `ParseResult` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::ParseResult.deinit
Signature
func deinit(self: protocol.redis.ParseResult) -> Void func deinit(self: protocol.redis.ParseResult) -> Void {
}
}@briefReleases fallback resources at the end of the `ParseResult` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::Reader.init
Signature
func init(self: protocol.redis.Reader, max_bulk_bytes: Int = 536870912, max_array_items: Int = 1048576) -> Void func init(self: protocol.redis.Reader, max_bulk_bytes: Int = 536870912, max_array_items: Int = 1048576) -> Void {
self.buf = "";
self.max_bulk_bytes = max_bulk_bytes;@briefInitializes a `Reader` instance.
@detailsEstablishes the initial field state for `Reader` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- max_bulk_bytesMaximum allowed count or byte size.
- max_array_itemsMaximum allowed count or byte size.
@returnVoid
functionprotocol.redis::Reader.feed
Signature
func feed(self: protocol.redis.Reader, data: String) -> Void func feed(self: protocol.redis.Reader, data: String) -> Void {
self.buf += data;
}@briefProvides the system library operation `Reader.feed`.
@detailsExecutes the `feed` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- dataInput or output data buffer.
@returnVoid
functionprotocol.redis::Reader.buffered_len
Signature
func buffered_len(self: protocol.redis.Reader) -> Int func buffered_len(self: protocol.redis.Reader) -> Int {
return std.len(self.buf);
}@briefProvides the system library operation `Reader.buffered_len`.
@detailsExecutes the `buffered_len` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionprotocol.redis::Reader.next
Signature
func next(self: protocol.redis.Reader) -> protocol.redis.RespValue, ErrCode func next(self: protocol.redis.Reader) -> protocol.redis.RespValue, ErrCode {
let parsed: protocol.redis.ParseResult = protocol.redis.parse_one(self.buf, 0, self.max_bulk_bytes, self.max_array_items)?;
if !parsed.complete {@briefProvides the system library operation `Reader.next`.
@detailsExecutes the `next` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `protocol.redis.RespValue, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::Reader.deinit
Signature
func deinit(self: protocol.redis.Reader) -> Void func deinit(self: protocol.redis.Reader) -> Void {
}
}@briefReleases fallback resources at the end of the `Reader` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionprotocol.redis::default_port
Signature
func default_port() -> Intfunc default_port() -> Int {
return 6379;
}@briefProvides the system library operation `default_port`.
@detailsExecutes the `default_port` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@returnReturns the operation result as `Int`.
functionprotocol.redis::resp_crlf
Signature
func resp_crlf() -> Stringfunc resp_crlf() -> String {
return "\r\n";
}@briefProvides the system library operation `resp_crlf`.
@detailsExecutes the `resp_crlf` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@returnReturns the operation result as `String`.
functionprotocol.redis::make_simple_string
Signature
func make_simple_string(text: String) -> protocol.redis.RespValuefunc make_simple_string(text: String) -> protocol.redis.RespValue {
let v: protocol.redis.RespValue = new protocol.redis.RespValue();
v.kind = protocol.redis.RESP_SIMPLE_STRING;@briefProvides the system library operation `make_simple_string`.
@detailsExecutes the `make_simple_string` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- textText input to parse, encode, format, search, or transmit.
@returnReturns the operation result as `protocol.redis.RespValue`.
functionprotocol.redis::make_bulk_string
Signature
func make_bulk_string(text: String) -> protocol.redis.RespValuefunc make_bulk_string(text: String) -> protocol.redis.RespValue {
let v: protocol.redis.RespValue = new protocol.redis.RespValue();
v.kind = protocol.redis.RESP_BULK_STRING;@briefProvides the system library operation `make_bulk_string`.
@detailsExecutes the `make_bulk_string` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- textText input to parse, encode, format, search, or transmit.
@returnReturns the operation result as `protocol.redis.RespValue`.
functionprotocol.redis::make_error
Signature
func make_error(text: String) -> protocol.redis.RespValuefunc make_error(text: String) -> protocol.redis.RespValue {
let v: protocol.redis.RespValue = new protocol.redis.RespValue();
v.kind = protocol.redis.RESP_ERROR;@briefProvides the system library operation `make_error`.
@detailsExecutes the `make_error` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- textText input to parse, encode, format, search, or transmit.
@returnReturns the operation result as `protocol.redis.RespValue`.
functionprotocol.redis::make_int
Signature
func make_int(value: Int) -> protocol.redis.RespValuefunc make_int(value: Int) -> protocol.redis.RespValue {
let v: protocol.redis.RespValue = new protocol.redis.RespValue();
v.kind = protocol.redis.RESP_INTEGER;@briefProvides the system library operation `make_int`.
@detailsExecutes the `make_int` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- valueValue to write or store.
@returnReturns the operation result as `protocol.redis.RespValue`.
functionprotocol.redis::make_null
Signature
func make_null() -> protocol.redis.RespValuefunc make_null() -> protocol.redis.RespValue {
return new protocol.redis.RespValue();
}@briefProvides the system library operation `make_null`.
@detailsExecutes the `make_null` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@returnReturns the operation result as `protocol.redis.RespValue`.
functionprotocol.redis::encode_command
Signature
func encode_command(args: collections.Vector<String>) -> Stringfunc encode_command(args: collections.Vector<String>) -> String {
let out: String = "*" + strconv.itoa(args.len()) + protocol.redis.resp_crlf();
loop (let i: Int = 0; i < args.len(); i += 1) {@briefEncodes input data with `encode_command`.
@detailsExecutes the `encode_command` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- argsArgument list forwarded to the command, process, callback, or formatter.
@returnReturns the operation result as `String`.
functionprotocol.redis::encode_command_items
Signature
func encode_command_items(items: ...String) -> Stringfunc encode_command_items(items: ...String) -> String {
return protocol.redis.encode_command(items);
}@briefEncodes input data with `encode_command_items`.
@detailsExecutes the `encode_command_items` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- itemsCollection of items inserted, removed, encoded, or returned by the operation.
@returnReturns the operation result as `String`.
functionprotocol.redis::command_args
Signature
func command_args(items: ...String) -> collections.Vector<String>func command_args(items: ...String) -> collections.Vector<String> {
let args: collections.Vector<String> = new collections.Vector<String>();
loop (let i: Int = 0; i < items.len(); i += 1) {@briefProvides the system library operation `command_args`.
@detailsExecutes the `command_args` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- itemsCollection of items inserted, removed, encoded, or returned by the operation.
@returnReturns the operation result as `collections.Vector<String>`.
functionprotocol.redis::command_with_values
Signature
func command_with_values(command_name: String, values: collections.Vector<String>) -> collections.Vector<String>func command_with_values(command_name: String, values: collections.Vector<String>) -> collections.Vector<String> {
let args: collections.Vector<String> = new collections.Vector<String>();
_ = args.push(command_name);@briefProvides the system library operation `command_with_values`.
@detailsExecutes the `command_with_values` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- command_nameProtocol command name to encode, send, dispatch, or execute.
- valuesValue supplied by the caller for storage, comparison, or encoding.
@returnReturns the operation result as `collections.Vector<String>`.
functionprotocol.redis::command_with_key_values
Signature
func command_with_key_values(command_name: String, key: String, values: collections.Vector<String>) -> collections.Vector<String>func command_with_key_values(command_name: String, key: String, values: collections.Vector<String>) -> collections.Vector<String> {
let args: collections.Vector<String> = new collections.Vector<String>();
_ = args.push(command_name);@briefProvides the system library operation `command_with_key_values`.
@detailsExecutes the `command_with_key_values` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- command_nameProtocol command name to encode, send, dispatch, or execute.
- keyKey name.
- valuesValue supplied by the caller for storage, comparison, or encoding.
@returnReturns the operation result as `collections.Vector<String>`.
functionprotocol.redis::parse_one
Signature
func parse_one(buf: String, start: Int = 0, max_bulk_bytes: Int = 536870912, max_array_items: Int = 1048576) -> protocol.redis.ParseResult, ErrCodefunc parse_one(buf: String, start: Int = 0, max_bulk_bytes: Int = 536870912, max_array_items: Int = 1048576) -> protocol.redis.ParseResult, ErrCode {
let out: protocol.redis.ParseResult = new protocol.redis.ParseResult();
if start >= std.len(buf) {@briefParses input data with `parse_one`.
@detailsExecutes the `parse_one` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- bufBuffer object or native buffer pointer used for reading, writing, or temporary storage.
- startZero-based starting index, byte offset, or range boundary for the operation.
- max_bulk_bytesMaximum allowed count or byte size.
- max_array_itemsMaximum allowed count or byte size.
@returnReturns `protocol.redis.ParseResult, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionprotocol.redis::parse_error_text
Signature
func parse_error_text(text: String) -> protocol.redis.RedisErrorfunc parse_error_text(text: String) -> protocol.redis.RedisError {
let e: protocol.redis.RedisError = new protocol.redis.RedisError();
e.message = text;@briefParses input data with `parse_error_text`.
@detailsExecutes the `parse_error_text` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- textText input to parse, encode, format, search, or transmit.
@returnReturns the operation result as `protocol.redis.RedisError`.
functionprotocol.redis::hash_tag
Signature
func hash_tag(key: String) -> Stringfunc hash_tag(key: String) -> String {
let open: Int = strings.find_substr(key, "{");
if open < 0 {@briefProvides the system library operation `hash_tag`.
@detailsExecutes the `hash_tag` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- keyKey name.
@returnReturns the operation result as `String`.
functionprotocol.redis::key_slot
Signature
func key_slot(key: String) -> Intfunc key_slot(key: String) -> Int {
return protocol.redis.crc16(protocol.redis.hash_tag(key)) % 16384;
}@briefProvides the system library operation `key_slot`.
@detailsExecutes the `key_slot` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- keyKey name.
@returnReturns the operation result as `Int`.
functionprotocol.redis::crc16
Signature
func crc16(data: String) -> Intfunc crc16(data: String) -> Int {
let crc: Int = 0;
loop (let i: Int = 0; i < std.len(data); i += 1) {@briefProvides the system library operation `crc16`.
@detailsExecutes the `crc16` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- dataInput or output data buffer.
@returnReturns the operation result as `Int`.
Variables
Class fields (var).
varprotocol.redis::Config.host
Type
String@brief`host` field.
@detailsStores a host name or network address. The field type is `String`, and it is maintained by the constructors and methods of `Config`.
var host: String;
/*
@brief `port` field.varprotocol.redis::Config.port
Type
Int@brief`port` field.
@detailsStores a port number. The field type is `Int`, and it is maintained by the constructors and methods of `Config`.
var port: Int;
/*
@brief `username` field.varprotocol.redis::Config.username
Type
String@brief`username` field.
@detailsHolds the `username` value for each `Config` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var username: String;
/*
@brief `password` field.varprotocol.redis::Config.password
Type
String@brief`password` field.
@detailsHolds the `password` value for each `Config` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var password: String;
/*
@brief `database` field.varprotocol.redis::Config.database
Type
Int@brief`database` field.
@detailsHolds the `database` value for each `Config` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var database: Int;
/*
@brief `timeout_ms` field.varprotocol.redis::Config.timeout_ms
Type
Int@brief`timeout_ms` field.
@detailsStores the default timeout in milliseconds. The field type is `Int`, and it is maintained by the constructors and methods of `Config`.
var timeout_ms: Int;
/*
@brief `read_timeout_ms` field.varprotocol.redis::Config.read_timeout_ms
Type
Int@brief`read_timeout_ms` field.
@detailsHolds the `read_timeout_ms` value for each `Config` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var read_timeout_ms: Int;
/*
@brief `write_timeout_ms` field.varprotocol.redis::Config.write_timeout_ms
Type
Int@brief`write_timeout_ms` field.
@detailsHolds the `write_timeout_ms` value for each `Config` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var write_timeout_ms: Int;
/*
@brief `use_tls` field.varprotocol.redis::Config.use_tls
Type
Bool@brief`use_tls` field.
@detailsHolds the `use_tls` value for each `Config` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var use_tls: Bool;
/*
@brief `tls_verify` field.varprotocol.redis::Config.tls_verify
Type
Bool@brief`tls_verify` field.
@detailsHolds the `tls_verify` value for each `Config` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var tls_verify: Bool;
/*
@brief `tls_ca_file` field.varprotocol.redis::Config.tls_ca_file
Type
String@brief`tls_ca_file` field.
@detailsHolds the `tls_ca_file` value for each `Config` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var tls_ca_file: String;
/*
@brief `protocol_version` field.varprotocol.redis::Config.protocol_version
Type
Int@brief`protocol_version` field.
@detailsHolds the `protocol_version` value for each `Config` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var protocol_version: Int;
/*
@brief `client_name` field.varprotocol.redis::Config.client_name
Type
String@brief`client_name` field.
@detailsHolds the `client_name` value for each `Config` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var client_name: String;
/*
@brief `max_bulk_bytes` field.varprotocol.redis::Config.max_bulk_bytes
Type
Int@brief`max_bulk_bytes` field.
@detailsHolds the `max_bulk_bytes` value for each `Config` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var max_bulk_bytes: Int;
/*
@brief `max_array_items` field.varprotocol.redis::Config.max_array_items
Type
Int@brief`max_array_items` field.
@detailsHolds the `max_array_items` value for each `Config` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var max_array_items: Int;
/*varprotocol.redis::RedisError.kind
Type
RedisErrorKind@brief`kind` field.
@detailsHolds the `kind` value for each `RedisError` instance. The field type is `RedisErrorKind`, and constructors and methods keep it synchronized with the object's runtime state.
var kind: RedisErrorKind;
/*
@brief `code` field.varprotocol.redis::RedisError.code
Type
String@brief`code` field.
@detailsHolds the `code` value for each `RedisError` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var code: String;
/*
@brief `message` field.varprotocol.redis::RedisError.message
Type
String@brief`message` field.
@detailsHolds the `message` value for each `RedisError` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var message: String;
/*
@brief `moved_slot` field.varprotocol.redis::RedisError.moved_slot
Type
Int@brief`moved_slot` field.
@detailsHolds the `moved_slot` value for each `RedisError` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var moved_slot: Int;
/*
@brief `moved_host` field.varprotocol.redis::RedisError.moved_host
Type
String@brief`moved_host` field.
@detailsHolds the `moved_host` value for each `RedisError` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var moved_host: String;
/*
@brief `moved_port` field.varprotocol.redis::RedisError.moved_port
Type
Int@brief`moved_port` field.
@detailsHolds the `moved_port` value for each `RedisError` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var moved_port: Int;
/*varprotocol.redis::RespValue.kind
Type
RespKind@brief`kind` field.
@detailsHolds the `kind` value for each `RespValue` instance. The field type is `RespKind`, and constructors and methods keep it synchronized with the object's runtime state.
var kind: RedisErrorKind;
/*
@brief `code` field.varprotocol.redis::RespValue.text
Type
String@brief`text` field.
@detailsHolds the `text` value for each `RespValue` instance. The field type is `String`, and constructors and methods keep it synchronized with the object's runtime state.
var text: String;
/*
@brief `int_value` field.varprotocol.redis::RespValue.int_value
Type
Int@brief`int_value` field.
@detailsHolds the `int_value` value for each `RespValue` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var int_value: Int;
/*
@brief `bool_value` field.varprotocol.redis::RespValue.bool_value
Type
Bool@brief`bool_value` field.
@detailsHolds the `bool_value` value for each `RespValue` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var bool_value: Bool;
/*
@brief `items` field.varprotocol.redis::RespValue.items
Type
collections.Vector<protocol.redis.RespValue>@brief`items` field.
@detailsHolds the `items` value for each `RespValue` instance. The field type is `collections.Vector<protocol.redis.RespValue>`, and constructors and methods keep it synchronized with the object's runtime state.
var items: collections.Vector<protocol.redis.RespValue>;
/*
@brief `attrs` field.varprotocol.redis::RespValue.attrs
Type
collections.Vector<protocol.redis.RespValue>@brief`attrs` field.
@detailsHolds the `attrs` value for each `RespValue` instance. The field type is `collections.Vector<protocol.redis.RespValue>`, and constructors and methods keep it synchronized with the object's runtime state.
var attrs: collections.Vector<protocol.redis.RespValue>;
/*varprotocol.redis::ParseResult.value
Type
protocol.redis.RespValue@brief`value` field.
@detailsHolds the `value` value for each `ParseResult` instance. The field type is `protocol.redis.RespValue`, and constructors and methods keep it synchronized with the object's runtime state.
var value: protocol.redis.RespValue;
/*
@brief `consumed` field.varprotocol.redis::ParseResult.consumed
Type
Int@brief`consumed` field.
@detailsHolds the `consumed` value for each `ParseResult` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var consumed: Int;
/*
@brief `complete` field.varprotocol.redis::ParseResult.complete
Type
Bool@brief`complete` field.
@detailsHolds the `complete` value for each `ParseResult` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var complete: Bool;
/*varprotocol.redis::Reader.buf
Type
String@brief`buf` field.
@detailsStores the internal buffer. The field type is `String`, and it is maintained by the constructors and methods of `Reader`.
var buf: String;
/*
@brief `max_bulk_bytes` field.varprotocol.redis::Reader.max_bulk_bytes
Type
Int@brief`max_bulk_bytes` field.
@detailsHolds the `max_bulk_bytes` value for each `Reader` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var max_bulk_bytes: Int;
/*
@brief `max_array_items` field.varprotocol.redis::Reader.max_array_items
Type
Int@brief`max_array_items` field.
@detailsHolds the `max_array_items` value for each `Reader` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var max_array_items: Int;
/*