db.redis #
Redis Client for V
This module provides a Redis client implementation in V that supports the Redis Serialization Protocol (RESP) versions 2 (RESP2) and 3 (RESP3) with a type-safe interface for common Redis commands.
Features
- Typed Commands: Strings, keys, hashes, lists, sets, sorted sets, and streams
- Pipelines and Transactions: Batch execution, optimistic locking, and per-command results
- Connections: Timeouts, TLS verification, reconnect controls, and
vlib/poolintegration - RESP Protocol Support: Full Redis Serialization Protocol implementation
- Advanced Features: Pub/Sub, bitmaps, HyperLogLog, geospatial search, scripting, and admin APIs
- Deployment Support: Redis Cluster routing and Sentinel master discovery
Quick Start
module main
import db.redis
fn main() {
// Connect to Redis
// Uncomment passwod line if authentication is needed
mut db := redis.connect(redis.Config{
// Available Config options (none of which need to be specified if you want the defauilts):
// host: 'localhost' - default
// password: 'your_password' - no default, you need to supply password if your redis server
// is set up to need one
// port: 6379 - default
// tls: false - default, set to true for ssl connection
})!
println('Server supports RESP${db.version} protocol')
// Set and get values
db.set('name', 'Alice')!
name := db.get[string]('name')!
println('Name: ${name}') // Output: Name: Alice
// Integer operations
db.set('counter', 42)!
db.incr('counter')!
counter := db.get[int]('counter')!
println('Counter: ${counter}') // Output: Counter: 43
// Clean up
db.close()!
}
Supported Commands
Key Operations
// Set value
db.set('key', 'value')!
db.set('number', 42)!
db.set('binary', []u8{len: 4, init: 0})!
// Get value
str_value := db.get[string]('key')!
int_value := db.get[int]('number')!
bin_value := db.get[[]u8]('binary')!
// Delete key
db.del('key')!
// Set expiration
db.expire('key', 60)! // 60 seconds
String and Key Commands
String commands include mget, mset, msetnx, setnx, setex, psetex, getdel, getex, incrby, decrby, incrbyfloat, append, strlen, getrange, and setrange. The value-taking commands accept strings, integers, or []u8, just like set.
db.mset({'first': 'Alice', 'second': ''})!
values := db.mget[string]('first', 'missing', 'second')!
// values is []?string: entries keep request order, and missing keys are none.
// An existing empty value is an option containing '', distinct from none.
// Set a value only when the key does not exist.
created := db.setnx('lock', 'owner')!
// Set a value with an expiration, or change expiration while reading it.
db.setex('cache', 60, 'value')!
value := db.getex[string]('cache', mode: .px, value: 5000)!
db.getex[string]('cache', mode: .persist)!
// Read and delete atomically.
previous := db.getdel[string]('cache')!
// Counters and byte ranges.
db.incrby('counter', 10)!
db.incrbyfloat('score', 0.5)!
db.append('first', ' Smith')!
part := db.getrange[string]('first', 0, 4)!
getdel and getex require Redis 6.2 or later. Like get, they return an error for a missing key. mget[T] and hmget[T] return nullable entries for strings, integers, or []u8. Scalar and multi-get unsigned reads preserve the full range of u64 and usize. GetExOptions selects one mode: .none, .ex, .px, .exat, .pxat, or .persist. The four expiration modes require a positive value; .none and .persist use zero.
Key commands include exists, ttl, pttl, pexpire, expireat, pexpireat, persist, keys, scan, key_type, rename, and unlink, in addition to del and expire. key_type sends Redis's TYPE command. exists returns the number of existing requested keys. ttl and pttl preserve Redis's negative results: -1 means no expiration, and -2 means that the key does not exist. unlink deletes one or more keys with asynchronous reclamation.
count := db.exists('first', 'second', 'missing')!
remaining_ms := db.pttl('first')!
db.pexpire('first', 5000)!
db.persist('first')!
kind := db.key_type('first')!
db.rename('first', 'renamed')!
db.unlink('renamed', 'second')!
scan and hscan accept ScanOptions with optional match and count fields. Both return (cursor, entries), where the cursor is a string. Start with '0' and continue until the returned cursor is '0'. A page can be empty before iteration finishes; count is a hint. hscan entries alternate field names and values. Redis may return duplicate entries while iterating, and callers should handle them when needed. Omitting match scans all entries; match: '' matches an empty key or field name.
mut cursor := '0'
for {
next, entries := db.scan(cursor, match: 'user:*', count: 100)!
for key in entries {
println(key)
}
cursor = next
if cursor == '0' {
break
}
}
Hash Operations
// Set hash fields
db.hset('user:1', {
'name': 'Bob',
'age': '30',
})!
// Get single field
name := db.hget[string]('user:1', 'name')!
// Get all fields
user_data := db.hgetall[string]('user:1')!
println(user_data) // Output: {'name': 'Bob', 'age': '30'}
Additional hash commands include hdel, hexists, hkeys, hvals, hlen, hincrby, hincrbyfloat, hmget, hscan, hstrlen, and hsetnx.
fields := db.hmget[string]('user:1', 'name', 'missing')!
has_name := db.hexists('user:1', 'name')!
db.hincrby('user:1', 'age', 1)!
db.hincrbyfloat('user:1', 'score', 0.5)!
names := db.hkeys('user:1')!
db.hdel('user:1', 'score')!
Pipeline Operations
The typed command wrappers support pipelines. While queued, they return zero, false, empty strings or collections, or the default generic value. Read the actual results from pipeline_execute(), which returns raw RedisValue replies in command order, including RedisNull for missing values. Command errors remain RedisBlobError entries, so later replies are consumed and the connection stays synchronized. Value and option validation happen before queueing.
// Start pipeline
db.pipeline_start()
// Queue commands
db.incr('counter')!
db.set('name', 'Charlie')!
db.get[string]('name')!
// Execute and get responses
responses := db.pipeline_execute()!
for resp in responses {
println(resp)
}
Lists, Sets, and Sorted Sets
List commands include pushes and pops, conditional pushes, indexing, range reads, insertion, removal, position lookup, moves, and multi-key pops. Blocking variants include blpop, brpop, blmove, and blmpop. ListSide selects .left or .right; ListInsertPosition selects .before or .after. Binary data is preserved in V strings.
db.rpush('queue', 'first', 'second')!
items := db.lrange('queue', 0, -1)!
item := db.lpop('queue')!
popped := db.blpop(['queue'], 0.5)!
// popped is ListPop{key, values}; a blocking timeout returns NilError.
Set commands include membership checks, random selection, moving members, intersections, unions, differences, stored combinations, cardinality queries, and sscan. smismember returns membership flags in request order. sintercard accepts an optional limit as its final integer argument (0 means unlimited).
db.sadd('tags', 'v', 'redis')!
present := db.sismember('tags', 'v')!
members := db.smembers('tags')!
shared := db.sinter('tags', 'other-tags')!
Sorted set commands include insertion, score changes, rank/score/lexicographic ranges, rank and score queries, random members, pops, blocking pops, removals, weighted combinations, intersection cardinality, and zscan. ZMember contains member and score. Range methods return member strings; _withscores variants return []ZMember under both RESP2 and RESP3. WeightedKey selects keys and weights; ZCombineOptions.aggregate selects .sum, .min, or .max.
db.zadd('scores', [redis.ZMember{member: 'Alice', score: 10}])!
db.zincrby('scores', 2.5, 'Alice')!
leaders := db.zrange_withscores('scores', 0, 9, rev: true)!
rank := db.zrevrank('scores', 'Alice')!
Single-value pops, missing indices, ranks, and scores return NilError. Methods ending in _count return collections and preserve empty results. zmscore preserves missing scores as nullable entries. Set iteration order is unspecified; scans can contain duplicate entries. lmpop, blmpop, sintercard, and zintercard require Redis 7.0 or later.
Transactions
multi, exec, discard, watch, and unwatch expose Redis transactions. Typed commands return placeholders while inside MULTI; actual results come from exec. A changed watched key makes exec return NilError. Runtime errors in individual commands remain RedisBlobError entries in the result array.
db.watch('balance')!
db.multi()!
db.incrby('balance', 10)!
results := db.exec()!
transaction_start buffers MULTI and subsequent commands locally. transaction_execute sends the batch and returns only the EXEC result. discard cancels either transaction form. reset clears queued bytes, discards server transactions, and removes watched keys before pool reuse. Reconnects are disabled while a transaction or WATCH is active.
Pub/Sub
Use connect_pubsub(config) for a dedicated subscription connection. It supports subscribe, psubscribe, unsubscribe, punsubscribe, and next_message under both RESP versions. PubSubMessage carries a channel, optional pattern, and binary payload in []u8. listen(callback) invokes the callback until it returns false; callback helpers also subscribe first. The subscription connection belongs to the caller running the listener.
mut sub := redis.connect_pubsub()!
defer { sub.close() or {} }
sub.subscribe('events')!
// Publish from a separate DB connection.
db.publish('events', 'hello')!
message := sub.next_message()!
println(message.payload.bytestr())
Streams
Stream commands include xadd, xread, xreadgroup, all xgroup management variants, xrange, xrevrange, xlen, xdel, xtrim, xack, xclaim, xautoclaim, xpending, and xinfo variants. StreamEntry contains an ID and a field/value map; strings preserve binary payloads. StreamOffset pairs a key with the requested read offset.
id := db.xadd('events', '*', {'kind': 'created'})!
entries := db.xrange('events', '-', '+')!
db.xgroup_create('events', 'workers', '0', mkstream: true)!
reads := db.xreadgroup('workers', 'worker-1', [redis.StreamOffset{key: 'events', id: '>'}])!
db.xack('events', 'workers', id)!
Redis blocking timeouts return empty stream collections. XReadOptions.block is nullable: omitted means nonblocking, while 0 blocks indefinitely at Redis. Configure the connection's read_timeout to allow the desired blocking duration. StreamTrim supports MAXLEN or MINID limits; XClaimOptions and XAutoClaimOptions select claim behavior. Claim ID-only variants and deleted IDs are preserved. xautoclaim requires Redis 6.2 or later.
Bitmaps, HyperLogLog, and Geospatial Commands
Bitmap methods include setbit, getbit, bitcount, bitpos, bitop, bitfield, and bitfield_ro. BitRange optionally selects byte or bit offsets. BitFieldOperation uses Redis encodings (i16, u8) and offsets (0, #2); overflow-failure results remain nullable. pfadd, pfcount, and pfmerge expose approximate HyperLogLog cardinality.
Geospatial methods include geoadd, geodist, geohash, geopos, geosearch, and geosearchstore, plus deprecated radius variants. GeoSearchOptions selects a center, circle or box, units, ordering, and optional distance/hash/coordinate metadata. Missing geohashes and positions are nullable. geosearch requires Redis 6.2 or later.
Scripting and Administration
Scripting methods include eval, evalsha, read-only variants, script_load, script_exists, script_flush, script_kill, fcall, and fcall_ro. Redis Function management supports loading, listing, deleting, flushing, dumping, restoring, statistics, and killing functions. Function calls require Redis 7.0 or later. Complex replies retain RedisValue shapes, including explicit nulls.
Server methods cover information, configuration, clients, replication, database counts, time, persistence, slow logs, memory, ACLs, command metadata, and cluster administration. server_time returns seconds and microseconds. RESP3 verbatim text replies are normalized to strings. ACL methods preserve raw structured replies where needed. Administrative commands retain their Redis side effects and permission checks.
monitor uses a dedicated connection; read events with monitor_next. client_reply('OFF') and client_reply('SKIP') send without reading a reply. Use a dedicated connection, send any suppressed commands through its transport, and restore replies with client_reply('ON') before calling other wrappers. quit closes the connection; shutdown accepts clean EOF before a response prefix as success and propagates incomplete replies, server errors, and timeouts.
Custom Commands
// Run raw commands
resp := db.cmd('SET', 'custom', 'value')!
result := db.cmd('GET', 'custom')!
// Complex commands
db.cmd('HSET', 'user:2', 'field1', 'value1', 'field2', '42')!
Error Handling
Commands return result types and preserve these error categories:
ConnectionError: dialing, transport closure, or timeoutCommandError: Redis error replies or invalid command optionsProtocolError: malformed frames or unexpected reply shapesAuthError: rejected authenticationNilError: a missing single value, blocking-pop timeout, or aborted transaction
Each type implements RedisError and V's IError; use err is redis.NilError, for example. Transport failures are distinct from server error replies. Detailed messages cover:
- Connection issues
- Protocol violations
- Type mismatches
- Redis error responses
- Timeout conditions
result := db.get[string]('nonexistent') or {
println('Key not found')
return
}
Connection Management
config := redis.Config{
host: 'redis.server'
port: 6379
}
mut db := redis.connect(config)!
defer {
db.close() or { eprintln('Error closing connection: ${err}') }
}
redis.DB also implements pool.ConnectionPoolable, so it can be used directly with vlib/pool connection pools.
Timeouts, TLS, and Reconnects
Config exposes connect_timeout, read_timeout, and write_timeout as time.Duration. Defaults are 5 seconds for TCP connection and 30 seconds for reads and writes. TCP connection timeouts cover the handshake after address resolution. TLS handshakes use connect_timeout; command I/O uses the read/write timeouts. Use net.infinite_timeout for unlimited I/O waits. Blocking Redis operations still need a sufficiently long client read timeout.
Authentication supports username (default: 'default') and password; database selects a logical database during connection. select_db changes it and retains it across reconnects. Named ACL users authenticate even with an empty password, including Redis users with nopass. Successful auth_user and hello calls with AUTH save their credentials for reconnects; failed authentication leaves the saved credentials unchanged. keep_alive enables TCP keepalive.
TLS configuration includes tls_validate, tls_ca, tls_cert, tls_key, tls_server_name, and tls_in_memory. Certificate verification remains opt-in for compatibility; enable it for verified TLS. CA and client credential fields are paths, or PEM strings when tls_in_memory is true. The server name controls SNI and hostname verification.
mut db := redis.connect(
host: 'redis.example.com'
tls: true
tls_validate: true
tls_ca: '/path/to/ca.pem'
tls_cert: '/path/to/client.pem'
tls_key: '/path/to/client.key'
connect_timeout: 2 * time.second
read_timeout: 5 * time.second
write_timeout: 5 * time.second
auto_reconnect: true
)!
reconnect restores authentication and the selected database. With auto_reconnect enabled, validate repairs a failed idle connection; later commands also reconnect a closed transport. max_retries and retry_delay control retries only when a failed write demonstrably sent zero bytes. Partially sent commands and failed reads are never replayed: their effects are unknown. Transport or protocol failures close the uncertain connection. Pipelines, transactions, and watched connections cannot reconnect automatically.
Redis is a mutable interface for raw commands, health checks, reset, and close, suitable for application mocks. Typed wrappers remain methods on DB.
Cluster and Sentinel
connect_cluster(seeds) discovers CLUSTER SLOTS and caches connections to owning nodes. hash_slot implements Redis CRC16 slots and hash tags. Cluster.cmd(key, ...args) uses the explicit routing key and follows bounded MOVED and ASK redirects; ASKING is sent before an ASK retry. Cluster.set and Cluster.get supply that key automatically. Multi-key commands must use keys with the same slot; automatic cross-slot splitting and cluster-wide pipelines are not provided. Cluster databases must be zero. Discovered nodes reuse the successful seed's authentication and TLS settings.
mut cluster := redis.connect_cluster([redis.Config{host: '127.0.0.1', port: 7000}])!
defer { cluster.close() or {} }
cluster.set('{user:1}:name', 'Alice')!
name := cluster.get[string]('{user:1}:name')!
connect_sentinel accepts SentinelConfig with separate Sentinel endpoints/credentials, master_name, and master_config. Discovery verifies that the returned node's ROLE is master. Sentinel.cmd rediscovers on connection failure for the next call, without replaying an uncertain command. A rejected READONLY command triggers discovery and one safe retry. Explicit reconnect forces discovery. Close the client when finished.
Concurrent Commands and Instrumentation
async_client(config).cmd_async(...args) returns a channel of AsyncResult. Each request runs on its own connection, so these independent calls do not share transaction state. AsyncResult.err retains the original error type; value contains the successful reply. Use vlib/pool and separate DB instances when concurrent workloads need connection reuse.
DB.statistics() returns command counts, failures, reconnects, and cumulative duration. Config.trace_hook receives a CommandTrace containing command name, elapsed time, and failure status. Failures track transport errors and direct Redis error replies; nested transaction errors remain result values. Traces never include keys, values, passwords, or full arguments. Each DB, Cluster, Sentinel, or PubSub instance belongs to one caller at a time.
Performance Tips
- Reuse Connections: Maintain connections instead of creating new ones
- Use Pipelines: Batch commands for high-throughput operations
- Prefer Integers: Use numeric types for counters and metrics
- Specify Types: Always specify return types for get operations
fn async_client #
fn async_client(config Config) AsyncClient
async_client creates a client for independent concurrent commands.
fn connect #
fn connect(config Config) !DB
connect establishes a connection and negotiates RESP3, with RESP2 fallback.
fn connect_cluster #
fn connect_cluster(seeds []Config) !Cluster
connect_cluster discovers the slot map from the first available seed. Config settings on that seed are reused for discovered nodes; clusters only support database zero.
fn connect_pubsub #
fn connect_pubsub(config Config) !PubSub
connect_pubsub opens a dedicated connection with the same configuration as connect.
fn connect_sentinel #
fn connect_sentinel(config SentinelConfig) !Sentinel
connect_sentinel discovers a master and verifies its ROLE before exposing it.
fn hash_slot #
fn hash_slot(key string) int
hash_slot returns Redis's CRC16 slot, honoring the first nonempty {...} hash tag.
interface Redis #
interface Redis {
mut:
cmd(...string) !RedisValue
ping() !string
close() !
validate() !bool
reset() !
}
Redis is the common command interface implemented by DB and mocks. Typed helpers remain on DB; cmd provides access to every Redis command.
interface RedisError #
interface RedisError {
msg() string
code() int
}
RedisError identifies errors returned by the Redis client.
type RedisValue #
type RedisValue = bool
| big.Integer
| f32
| f64
| i64
| []u8
| RedisBlobError
| RedisMap
| RedisNull
| RedisPush
| RedisSet
| map[string]RedisValue
| []RedisValue
| RedisVerbatim
| string
RedisValue represents all possible RESP (Redis Serialization Protocol) data types
enum BitFieldKind #
enum BitFieldKind {
get
set
incrby
}
BitFieldKind selects the operation performed on a bitfield.
enum BitOperation #
enum BitOperation {
and
or
xor
not
}
BitOperation selects a bitwise operation for bitop.
enum BitOverflow #
enum BitOverflow {
default
wrap
sat
fail
}
BitOverflow selects bitfield overflow behavior; default emits no OVERFLOW directive.
enum BitUnit #
enum BitUnit {
byte
bit
}
BitUnit selects the unit used by a bitmap range.
enum GeoAddMode #
enum GeoAddMode {
all
nx
xx
}
GeoAddMode controls whether geoadd inserts new members or updates existing members.
enum GeoOrder #
enum GeoOrder {
unsorted
asc
desc
}
GeoOrder selects distance ordering for geospatial searches.
enum GeoUnit #
enum GeoUnit {
m
km
ft
mi
}
GeoUnit selects the unit for geospatial distances and search dimensions.
enum GetExMode #
enum GetExMode {
none
ex
px
exat
pxat
persist
}
GetExMode selects the expiration operation performed by getex.
enum ListInsertPosition #
enum ListInsertPosition {
before
after
}
ListInsertPosition selects where linsert places an element relative to its pivot.
enum ListSide #
enum ListSide {
left
right
}
ListSide selects the end of a list for pop and move operations.
enum ZAggregate #
enum ZAggregate {
sum
min
max
}
ZAggregate selects how sorted set union and intersection combine scores.
struct AsyncClient #
struct AsyncClient {
pub:
config Config
}
AsyncClient runs independent commands on separate connections using V coroutines. Each request owns its connection; transaction and pipeline state is never shared.
fn (AsyncClient) cmd_async #
fn (client AsyncClient) cmd_async(args ...string) chan AsyncResult
cmd_async starts a command and returns a channel carrying exactly one result.
struct AsyncResult #
struct AsyncResult {
pub:
value RedisValue = RedisNull{}
err ?IError
}
AsyncResult contains a command reply or the original error.
struct AuthError #
struct AuthError {
pub:
message string
}
AuthError represents an authentication failure.
fn (AuthError) msg #
fn (e AuthError) msg() string
msg returns the error message.
fn (AuthError) code #
fn (e AuthError) code() int
code returns the Redis client error category.
struct BitFieldOperation #
struct BitFieldOperation {
pub:
kind BitFieldKind
encoding string
offset string
value i64
overflow BitOverflow
}
BitFieldOperation addresses a signed or unsigned integer at a bit offset. Encoding uses Redis syntax, such as i16 or u8. Offset also accepts indexed offsets like #2.
struct BitRange #
struct BitRange {
pub:
start ?i64
end ?i64
unit BitUnit
}
BitRange configures an inclusive byte or bit range for bitcount and bitpos.
struct Cluster #
struct Cluster {
mut:
config Config
slots []string
nodes map[string]&DB
}
Cluster routes commands by hash slot and follows MOVED and ASK redirects. One Cluster belongs to one caller; use separate clients for concurrent requests.
fn (Cluster) refresh_slots #
fn (mut cluster Cluster) refresh_slots() !
refresh_slots atomically replaces the slot map using CLUSTER SLOTS.
fn (Cluster) cmd #
fn (mut cluster Cluster) cmd(key string, args ...string) !RedisValue
cmd routes a command using key, which must identify the command's Redis hash slot. All keys in a multi-key command must share that slot. Server-side redirects are bounded to 16 hops.
fn (Cluster) set #
fn (mut cluster Cluster) set[T](key string, value T) !string
set stores a value on its owning cluster node.
fn (Cluster) get #
fn (mut cluster Cluster) get[T](key string) !T
get reads a value from its owning cluster node.
fn (Cluster) close #
fn (mut cluster Cluster) close() !
close closes every cached cluster connection.
struct CommandError #
struct CommandError {
pub:
message string
}
CommandError represents a Redis command error reply.
fn (CommandError) msg #
fn (e CommandError) msg() string
msg returns the error message.
fn (CommandError) code #
fn (e CommandError) code() int
code returns the Redis client error category.
struct CommandTrace #
struct CommandTrace {
pub:
command string
duration time.Duration
failed bool
}
CommandTrace describes a completed command without including keys, values, or credentials.
struct Config #
struct Config {
pub mut:
host string = '127.0.0.1'
port u16 = 6379
username string = 'default'
password string
database int
tls bool
tls_validate bool
tls_ca string
tls_cert string
tls_key string
tls_server_name string
tls_in_memory bool
connect_timeout time.Duration = 5 * time.second
read_timeout time.Duration = 30 * time.second
write_timeout time.Duration = 30 * time.second
keep_alive bool
auto_reconnect bool
max_retries int
retry_delay time.Duration = 100 * time.millisecond
trace_hook ?fn (CommandTrace)
version int @[deprecated]
}
Config controls connection, authentication, timeouts, and TLS settings.
struct ConnectionError #
struct ConnectionError {
pub:
message string
eof bool // true only when the peer closed the transport cleanly
}
ConnectionError represents a connection or transport failure.
fn (ConnectionError) msg #
fn (e ConnectionError) msg() string
msg returns the error message.
fn (ConnectionError) code #
fn (e ConnectionError) code() int
code returns the Redis client error category.
struct DB #
struct DB {
pub mut:
version int // RESP protocol version
conn &net.TcpConn = unsafe { nil } // TCP connection to Redis
ssl_conn &ssl.SSLConn = unsafe { nil } // SSL connection to Redis
tls bool
// Pre-allocated buffers to reduce memory allocations
cmd_buf []u8 // Buffer for building commands
resp_buf []u8 // Buffer for reading responses
transaction_mode bool
buffered_transaction bool
watched bool
closed bool
config Config
metrics Metrics
pipeline_mode bool
pipeline_buffer []u8
pipeline_cmd_count int
}
DB represents a Redis database connection
fn (DB) setbit #
fn (mut db DB) setbit(key string, offset i64, value bool) !bool
setbit sets a bit and returns its previous value.
fn (DB) getbit #
fn (mut db DB) getbit(key string, offset i64) !bool
getbit retrieves a bit; bits beyond the value's length are false.
fn (DB) bitcount #
fn (mut db DB) bitcount(key string, options BitRange) !i64
bitcount counts set bits in a string or an inclusive byte or bit range.
fn (DB) bitpos #
fn (mut db DB) bitpos(key string, value bool, options BitRange) !i64
bitpos finds the first matching bit; -1 means no matching bit was found.
fn (DB) bitop #
fn (mut db DB) bitop(operation BitOperation, destination string, keys ...string) !i64
bitop stores a bitwise operation over source strings and returns the destination length.
fn (DB) bitfield #
fn (mut db DB) bitfield(key string, operations ...BitFieldOperation) ![]?i64
bitfield performs integer operations on bitfields; failed overflow operations return none.
fn (DB) bitfield_ro #
fn (mut db DB) bitfield_ro(key string, operations ...BitFieldOperation) ![]?i64
bitfield_ro reads bitfields without modifying the key.
fn (DB) pfadd #
fn (mut db DB) pfadd(key string, elements ...string) !bool
pfadd adds elements to a HyperLogLog and reports whether its registers changed.
fn (DB) pfcount #
fn (mut db DB) pfcount(keys ...string) !i64
pfcount estimates the cardinality of the union of HyperLogLogs.
fn (DB) pfmerge #
fn (mut db DB) pfmerge(destination string, keys ...string) !string
pfmerge stores the union of source HyperLogLogs in destination.
fn (DB) mget #
fn (mut db DB) mget[T](keys ...string) ![]?T
mget retrieves values in key order, preserving missing keys as none. Supported return types are string, integer types, and []u8.
fn (DB) mset #
fn (mut db DB) mset[T](values map[string]T) !string
mset atomically stores multiple keys. Supported value types are string, integer types, and []u8.
fn (DB) msetnx #
fn (mut db DB) msetnx[T](values map[string]T) !bool
msetnx atomically stores multiple keys only when none of them exists.
fn (DB) setnx #
fn (mut db DB) setnx[T](key string, value T) !bool
setnx stores a key only when it does not exist.
fn (DB) setex #
fn (mut db DB) setex[T](key string, seconds i64, value T) !string
setex stores a value with an expiration time in seconds.
fn (DB) psetex #
fn (mut db DB) psetex[T](key string, milliseconds i64, value T) !string
psetex stores a value with an expiration time in milliseconds.
fn (DB) getdel #
fn (mut db DB) getdel[T](key string) !T
getdel retrieves and deletes a string key, returning an error if the key is missing.
fn (DB) getex #
fn (mut db DB) getex[T](key string, options GetExOptions) !T
getex retrieves a string key and optionally changes or removes its expiration. Missing keys return an error. Timed modes require a positive value.
fn (DB) incrby #
fn (mut db DB) incrby(key string, increment i64) !i64
incrby increments an integer key by the given amount.
fn (DB) decrby #
fn (mut db DB) decrby(key string, decrement i64) !i64
decrby decrements an integer key by the given amount.
fn (DB) incrbyfloat #
fn (mut db DB) incrbyfloat(key string, increment f64) !f64
incrbyfloat increments a numeric key by the given floating point amount.
fn (DB) exists #
fn (mut db DB) exists(keys ...string) !i64
exists counts the specified keys that exist, counting repeated keys separately.
fn (DB) ttl #
fn (mut db DB) ttl(key string) !i64
ttl returns the remaining lifetime in seconds, or -1 without expiration and -2 for a missing key.
fn (DB) pttl #
fn (mut db DB) pttl(key string) !i64
pttl returns the remaining lifetime in milliseconds, or -1 without expiration and -2 if missing.
fn (DB) pexpire #
fn (mut db DB) pexpire(key string, milliseconds i64) !bool
pexpire sets a key's expiration in milliseconds and reports whether it was set.
fn (DB) expireat #
fn (mut db DB) expireat(key string, timestamp i64) !bool
expireat sets a key's expiration to a Unix timestamp in seconds.
fn (DB) pexpireat #
fn (mut db DB) pexpireat(key string, timestamp i64) !bool
pexpireat sets a key's expiration to a Unix timestamp in milliseconds.
fn (DB) persist #
fn (mut db DB) persist(key string) !bool
persist removes a key's expiration and reports whether an expiration was removed.
fn (DB) unlink #
fn (mut db DB) unlink(keys ...string) !i64
unlink removes keys, reclaiming their memory asynchronously.
fn (DB) keys #
fn (mut db DB) keys(pattern string) ![]string
keys returns all keys matching a pattern. Use scan for incremental iteration over large databases.
fn (DB) scan #
fn (mut db DB) scan(cursor string, options ScanOptions) !(string, []string)
scan returns the next cursor and matching keys. Continue until the cursor is '0'.
fn (DB) key_type #
fn (mut db DB) key_type(key string) !string
key_type returns the Redis type of a key, or 'none' if the key does not exist.
fn (DB) rename #
fn (mut db DB) rename(key string, new_key string) !string
rename renames a key, replacing any existing destination key.
fn (DB) hdel #
fn (mut db DB) hdel(key string, fields ...string) !i64
hdel removes hash fields and returns the number removed.
fn (DB) hexists #
fn (mut db DB) hexists(key string, field string) !bool
hexists reports whether a hash field exists.
fn (DB) hkeys #
fn (mut db DB) hkeys(key string) ![]string
hkeys returns all field names in a hash.
fn (DB) hvals #
fn (mut db DB) hvals(key string) ![]string
hvals returns all values in a hash as strings.
fn (DB) hlen #
fn (mut db DB) hlen(key string) !i64
hlen returns the number of fields in a hash.
fn (DB) hstrlen #
fn (mut db DB) hstrlen(key string, field string) !i64
hstrlen returns the byte length of a hash field's value, or zero for a missing field.
fn (DB) hsetnx #
fn (mut db DB) hsetnx[T](key string, field string, value T) !bool
hsetnx stores a hash field only when it does not exist.
fn (DB) hincrby #
fn (mut db DB) hincrby(key string, field string, increment i64) !i64
hincrby increments an integer hash field by the given amount.
fn (DB) hincrbyfloat #
fn (mut db DB) hincrbyfloat(key string, field string, increment f64) !f64
hincrbyfloat increments a numeric hash field by the given floating point amount.
fn (DB) hmget #
fn (mut db DB) hmget[T](key string, fields ...string) ![]?T
hmget retrieves hash field values in field order, preserving missing fields as none. Supported return types are string, integer types, and []u8.
fn (DB) hscan #
fn (mut db DB) hscan(key string, cursor string, options ScanOptions) !(string, []string)
hscan returns the next cursor and alternating field/value strings for a hash. Continue until the cursor is '0'.
fn (DB) append #
fn (mut db DB) append[T](key string, value T) !i64
append appends a value to a string key and returns the resulting byte length.
fn (DB) strlen #
fn (mut db DB) strlen(key string) !i64
strlen returns the byte length of a string key, or zero if the key is missing.
fn (DB) getrange #
fn (mut db DB) getrange[T](key string, start i64, end i64) !T
getrange retrieves a string key's byte range using inclusive start and end offsets.
fn (DB) setrange #
fn (mut db DB) setrange[T](key string, offset i64, value T) !i64
setrange overwrites a string key starting at the byte offset and returns its resulting length.
fn (DB) statistics #
fn (db DB) statistics() Metrics
statistics returns the connection's command and reconnect counters.
fn (DB) reconnect #
fn (mut db DB) reconnect() !
reconnect replaces the transport and restores authentication and the selected database. Pending pipelines and transactions cannot be replayed and must be discarded explicitly.
fn (DB) select_db #
fn (mut db DB) select_db(database int) !string
select_db selects a logical database and remembers it for reconnects.
fn (DB) lpush #
fn (mut db DB) lpush(key string, values ...string) !i64
lpush prepends values and returns the resulting list length.
fn (DB) rpush #
fn (mut db DB) rpush(key string, values ...string) !i64
rpush appends values and returns the resulting list length.
fn (DB) lpushx #
fn (mut db DB) lpushx(key string, values ...string) !i64
lpushx prepends values only when the list already exists.
fn (DB) rpushx #
fn (mut db DB) rpushx(key string, values ...string) !i64
rpushx appends values only when the list already exists.
fn (DB) lpop #
fn (mut db DB) lpop(key string) !string
lpop removes the first list element, returning NilError for an empty or missing list.
fn (DB) rpop #
fn (mut db DB) rpop(key string) !string
rpop removes the last list element, returning NilError for an empty or missing list.
fn (DB) lpop_count #
fn (mut db DB) lpop_count(key string, count int) ![]string
lpop_count removes up to count elements from the start, returning an empty array if missing.
fn (DB) rpop_count #
fn (mut db DB) rpop_count(key string, count int) ![]string
rpop_count removes up to count elements from the end, returning an empty array if missing.
fn (DB) rpoplpush #
fn (mut db DB) rpoplpush(source string, destination string) !string
rpoplpush moves the last source element to the start of destination. Prefer lmove.
fn (DB) llen #
fn (mut db DB) llen(key string) !i64
llen returns the number of elements in a list.
fn (DB) lrange #
fn (mut db DB) lrange(key string, start i64, stop i64) ![]string
lrange returns elements at inclusive offsets, supporting negative offsets from the end.
fn (DB) lindex #
fn (mut db DB) lindex(key string, index i64) !string
lindex returns the element at an offset, or NilError if the offset or list is missing.
fn (DB) lset #
fn (mut db DB) lset(key string, index i64, value string) !string
lset replaces the element at an offset.
fn (DB) ltrim #
fn (mut db DB) ltrim(key string, start i64, stop i64) !string
ltrim retains only the elements at inclusive offsets.
fn (DB) linsert #
fn (mut db DB) linsert(key string, position ListInsertPosition, pivot string, value string) !i64
linsert inserts a value relative to a pivot, returning -1 if the pivot is missing.
fn (DB) lrem #
fn (mut db DB) lrem(key string, count i64, value string) !i64
lrem removes matching values. Count zero removes all; negative counts start at the end.
fn (DB) lpos #
fn (mut db DB) lpos(key string, value string) !i64
lpos returns the first matching index, or NilError if the value is absent.
fn (DB) blpop #
fn (mut db DB) blpop(keys []string, timeout f64) !ListPop
blpop waits up to timeout seconds for an element from the start of the first nonempty list. A zero timeout waits indefinitely; an elapsed timeout returns NilError.
fn (DB) brpop #
fn (mut db DB) brpop(keys []string, timeout f64) !ListPop
brpop waits up to timeout seconds for an element from the end of the first nonempty list.
fn (DB) lmove #
fn (mut db DB) lmove(source string, destination string, from ListSide, to ListSide) !string
lmove atomically moves an element between the selected ends of two lists.
fn (DB) blmove #
fn (mut db DB) blmove(source string, destination string, from ListSide, to ListSide, timeout f64) !string
blmove blocks up to timeout seconds while moving an element between two lists.
fn (DB) lmpop #
fn (mut db DB) lmpop(keys []string, side ListSide, count int) !ListPop
lmpop removes up to count elements from the first nonempty list, or returns NilError.
fn (DB) blmpop #
fn (mut db DB) blmpop(timeout f64, keys []string, side ListSide, count int) !ListPop
blmpop blocks up to timeout seconds while removing elements from the first nonempty list.
fn (DB) sadd #
fn (mut db DB) sadd(key string, members ...string) !i64
sadd adds members to a set and returns the number of newly added members.
fn (DB) srem #
fn (mut db DB) srem(key string, members ...string) !i64
srem removes members from a set and returns the number removed.
fn (DB) smembers #
fn (mut db DB) smembers(key string) ![]string
smembers returns the unordered members of a set under either RESP version.
fn (DB) sismember #
fn (mut db DB) sismember(key string, member string) !bool
sismember reports whether a member belongs to a set.
fn (DB) smismember #
fn (mut db DB) smismember(key string, members ...string) ![]bool
smismember reports membership for each member in input order.
fn (DB) scard #
fn (mut db DB) scard(key string) !i64
scard returns the number of members in a set.
fn (DB) spop #
fn (mut db DB) spop(key string) !string
spop removes a random member, or returns NilError for an empty or missing set.
fn (DB) spop_count #
fn (mut db DB) spop_count(key string, count int) ![]string
spop_count removes up to count random members, returning an empty array if missing.
fn (DB) srandmember #
fn (mut db DB) srandmember(key string) !string
srandmember returns a random member without removing it, or NilError if missing.
fn (DB) srandmember_count #
fn (mut db DB) srandmember_count(key string, count int) ![]string
srandmember_count returns count random members; negative counts permit repeated members.
fn (DB) smove #
fn (mut db DB) smove(source string, destination string, member string) !bool
smove moves a member between sets and reports whether it was present in the source.
fn (DB) sinter #
fn (mut db DB) sinter(keys ...string) ![]string
sinter returns the intersection of sets.
fn (DB) sinterstore #
fn (mut db DB) sinterstore(destination string, keys ...string) !i64
sinterstore replaces destination with the intersection and returns its cardinality.
fn (DB) sintercard #
fn (mut db DB) sintercard(keys []string, limit int) !i64
sintercard counts the intersection, optionally stopping at a positive limit.
fn (DB) sunion #
fn (mut db DB) sunion(keys ...string) ![]string
sunion returns the union of sets.
fn (DB) sunionstore #
fn (mut db DB) sunionstore(destination string, keys ...string) !i64
sunionstore replaces destination with the union and returns its cardinality.
fn (DB) sdiff #
fn (mut db DB) sdiff(keys ...string) ![]string
sdiff returns members of the first set that occur in none of the remaining sets.
fn (DB) sdiffstore #
fn (mut db DB) sdiffstore(destination string, keys ...string) !i64
sdiffstore replaces destination with the set difference and returns its cardinality.
fn (DB) sscan #
fn (mut db DB) sscan(key string, cursor string, options ScanOptions) !(string, []string)
sscan returns the next cursor and a batch of set members; continue until cursor is '0'.
fn (DB) zadd #
fn (mut db DB) zadd(key string, members ...ZMember) !i64
zadd adds or updates sorted set members and returns the number of newly added members.
fn (DB) zadd_with_options #
fn (mut db DB) zadd_with_options(key string, options ZAddOptions, members ...ZMember) !i64
zadd_with_options adds or updates members using conditional and change-counting options.
fn (DB) zrem #
fn (mut db DB) zrem(key string, members ...string) !i64
zrem removes sorted set members and returns the number removed.
fn (DB) zcard #
fn (mut db DB) zcard(key string) !i64
zcard returns the number of sorted set members.
fn (DB) zcount #
fn (mut db DB) zcount(key string, min string, max string) !i64
zcount counts scores within bounds, supporting infinity and exclusive '(value' bounds.
fn (DB) zscore #
fn (mut db DB) zscore(key string, member string) !f64
zscore returns a member's score, or NilError if the member is missing.
fn (DB) zmscore #
fn (mut db DB) zmscore(key string, members ...string) ![]?f64
zmscore returns scores in input order, preserving missing members as none.
fn (DB) zincrby #
fn (mut db DB) zincrby(key string, increment f64, member string) !f64
zincrby increments a member's score, creating the member if necessary.
fn (DB) zrank #
fn (mut db DB) zrank(key string, member string) !i64
zrank returns a member's zero-based ascending rank, or NilError if missing.
fn (DB) zrevrank #
fn (mut db DB) zrevrank(key string, member string) !i64
zrevrank returns a member's zero-based descending rank, or NilError if missing.
fn (DB) zrange #
fn (mut db DB) zrange(key string, start i64, stop i64, options ZRangeOptions) ![]string
zrange returns members at inclusive rank offsets, optionally in reverse order.
fn (DB) zrange_withscores #
fn (mut db DB) zrange_withscores(key string, start i64, stop i64, options ZRangeOptions) ![]ZMember
zrange_withscores returns members and scores at inclusive rank offsets.
fn (DB) zrevrange #
fn (mut db DB) zrevrange(key string, start i64, stop i64) ![]string
zrevrange returns members at inclusive rank offsets in descending order.
fn (DB) zrevrange_withscores #
fn (mut db DB) zrevrange_withscores(key string, start i64, stop i64) ![]ZMember
zrevrange_withscores returns members and scores in descending rank order.
fn (DB) zrangebyscore #
fn (mut db DB) zrangebyscore(key string, min string, max string, options ZRangeLimit) ![]string
zrangebyscore returns members within score bounds, with optional offset and count.
fn (DB) zrangebyscore_withscores #
fn (mut db DB) zrangebyscore_withscores(key string, min string, max string, options ZRangeLimit) ![]ZMember
zrangebyscore_withscores returns members and scores within score bounds.
fn (DB) zrangebylex #
fn (mut db DB) zrangebylex(key string, min string, max string, options ZRangeLimit) ![]string
zrangebylex returns members within lexicographic bounds for a set whose scores are equal.
fn (DB) zpopmax #
fn (mut db DB) zpopmax(key string, count ...int) ![]ZMember
zpopmax removes the highest scoring members; omitted count defaults to one.
fn (DB) zpopmin #
fn (mut db DB) zpopmin(key string, count ...int) ![]ZMember
zpopmin removes the lowest scoring members; omitted count defaults to one.
fn (DB) bzpopmax #
fn (mut db DB) bzpopmax(timeout f64, keys ...string) !ZPop
bzpopmax blocks up to timeout seconds for the highest scoring member of the first nonempty set.
fn (DB) bzpopmin #
fn (mut db DB) bzpopmin(timeout f64, keys ...string) !ZPop
bzpopmin blocks up to timeout seconds for the lowest scoring member of the first nonempty set.
fn (DB) zrandmember #
fn (mut db DB) zrandmember(key string) !string
zrandmember returns a random member without removing it, or NilError if missing.
fn (DB) zrandmember_count #
fn (mut db DB) zrandmember_count(key string, count int) ![]string
zrandmember_count returns random members; negative counts permit repeated members.
fn (DB) zrandmember_withscores #
fn (mut db DB) zrandmember_withscores(key string, count int) ![]ZMember
zrandmember_withscores returns random members with scores, permitting repeats for negative count.
fn (DB) zdiff #
fn (mut db DB) zdiff(keys ...string) ![]string
zdiff returns the sorted set difference of the given keys.
fn (DB) zdiff_withscores #
fn (mut db DB) zdiff_withscores(keys ...string) ![]ZMember
zdiff_withscores returns the sorted set difference with scores from the first set.
fn (DB) zdiffstore #
fn (mut db DB) zdiffstore(destination string, keys ...string) !i64
zdiffstore replaces destination with the difference and returns its cardinality.
fn (DB) zinter #
fn (mut db DB) zinter(keys []WeightedKey, options ZCombineOptions) ![]string
zinter returns the weighted intersection of sorted sets.
fn (DB) zinter_withscores #
fn (mut db DB) zinter_withscores(keys []WeightedKey, options ZCombineOptions) ![]ZMember
zinter_withscores returns members and aggregate scores in a weighted intersection.
fn (DB) zinterstore #
fn (mut db DB) zinterstore(destination string, keys []WeightedKey, options ZCombineOptions) !i64
zinterstore replaces destination with a weighted intersection and returns its cardinality.
fn (DB) zunion #
fn (mut db DB) zunion(keys []WeightedKey, options ZCombineOptions) ![]string
zunion returns the weighted union of sorted sets.
fn (DB) zunion_withscores #
fn (mut db DB) zunion_withscores(keys []WeightedKey, options ZCombineOptions) ![]ZMember
zunion_withscores returns members and aggregate scores in a weighted union.
fn (DB) zunionstore #
fn (mut db DB) zunionstore(destination string, keys []WeightedKey, options ZCombineOptions) !i64
zunionstore replaces destination with a weighted union and returns its cardinality.
fn (DB) zintercard #
fn (mut db DB) zintercard(keys []string, limit int) !i64
zintercard counts the intersection, optionally stopping at a positive limit.
fn (DB) zlexcount #
fn (mut db DB) zlexcount(key string, min string, max string) !i64
zlexcount counts members within lexicographic bounds for a set whose scores are equal.
fn (DB) zremrangebyrank #
fn (mut db DB) zremrangebyrank(key string, start i64, stop i64) !i64
zremrangebyrank removes members at inclusive rank offsets.
fn (DB) zremrangebyscore #
fn (mut db DB) zremrangebyscore(key string, min string, max string) !i64
zremrangebyscore removes members within score bounds.
fn (DB) zremrangebylex #
fn (mut db DB) zremrangebylex(key string, min string, max string) !i64
zremrangebylex removes members within lexicographic bounds.
fn (DB) zscan #
fn (mut db DB) zscan(key string, cursor string, options ScanOptions) !(string, []ZMember)
zscan returns the next cursor and a batch of members and scores; continue until cursor is '0'.
fn (DB) geoadd #
fn (mut db DB) geoadd(key string, members []GeoMember, options GeoAddOptions) !i64
geoadd adds or updates positions and returns the number of new or changed members.
fn (DB) geodist #
fn (mut db DB) geodist(key string, first string, second string, unit GeoUnit) !f64
geodist returns the distance between members; a missing member returns an error.
fn (DB) geohash #
fn (mut db DB) geohash(key string, members ...string) ![]?string
geohash returns geohashes in member order, preserving missing members as none.
fn (DB) geopos #
fn (mut db DB) geopos(key string, members ...string) ![]?GeoPosition
geopos returns positions in member order, preserving missing members as none.
fn (DB) geosearch #
fn (mut db DB) geosearch(key string, options GeoSearchOptions) ![]GeoSearchResult
geosearch searches a geospatial index in a circle or box.
fn (DB) geosearchstore #
fn (mut db DB) geosearchstore(destination string, source string, options GeoSearchOptions, store_dist bool) !i64
geosearchstore stores search results as a sorted set, optionally using distance as score.
fn (DB) georadius #
fn (mut db DB) georadius(key string, options GeoSearchOptions) ![]GeoSearchResult
georadius searches a circle centered on coordinates using the legacy Redis command. Prefer geosearch for new code. Options must describe a circle centered on coordinates.
fn (DB) georadiusbymember #
fn (mut db DB) georadiusbymember(key string, options GeoSearchOptions) ![]GeoSearchResult
georadiusbymember searches a circle centered on a member using the legacy Redis command. Prefer geosearch for new code. Options must describe a circle centered on a member.
fn (DB) publish #
fn (mut db DB) publish[T](channel string, message T) !i64
publish sends a message to subscribers and returns the number of receiving subscriptions.
fn (DB) close #
fn (mut db DB) close() !
close terminates the connection to Redis server
fn (DB) auth #
fn (mut db DB) auth(password string) !
auth sends an AUTH command to the server with the given password.
fn (DB) auth_user #
fn (mut db DB) auth_user(username string, password string) !
auth_user authenticates a Redis ACL user, or the default user when username is empty.
fn (DB) ping #
fn (mut db DB) ping() !string
ping sends a PING command to verify server responsiveness
fn (DB) validate #
fn (mut db DB) validate() !bool
validate checks whether the Redis connection is still responsive.
fn (DB) reset #
fn (mut db DB) reset() !
reset discards transactions, removes WATCH state, and clears queued commands before pool reuse.
fn (DB) del #
fn (mut db DB) del(key string) !i64
del deletes a key
fn (DB) set #
fn (mut db DB) set[T](key string, value T) !string
set stores a key-value pair in Redis. Supported value types: integer, string, []u8.
fn (DB) get #
fn (mut db DB) get[T](key string) !T
get retrieves the value of a key. Supported return types: string, integer, []u8.
fn (DB) incr #
fn (mut db DB) incr(key string) !i64
incr increments the integer value of a key by 1
fn (DB) decr #
fn (mut db DB) decr(key string) !i64
decr decrements the integer value of a key by 1
fn (DB) hset #
fn (mut db DB) hset[T](key string, m map[string]T) !int
hset sets multiple fields in a hash. Supported value types: string, integer, []u8.
fn (DB) hget #
fn (mut db DB) hget[T](key string, m_key string) !T
hget retrieves a hash field. Supported return types: string, integer, []u8.
fn (DB) hgetall #
fn (mut db DB) hgetall[T](key string) !map[string]T
hgetall retrieves all fields and values of a hash. Supported value types: string, int, []u8
fn (DB) expire #
fn (mut db DB) expire(key string, seconds int) !bool
expire sets a key's time to live in seconds
fn (DB) cmd #
fn (mut db DB) cmd(cmd ...string) !RedisValue
cmd sends a custom command to Redis server. For example: db.cmd('SET', 'key', 'value')!
fn (DB) pipeline_start #
fn (mut db DB) pipeline_start()
pipeline_start starts a buffered command pipeline.
fn (DB) pipeline_execute #
fn (mut db DB) pipeline_execute() ![]RedisValue
pipeline_execute sends queued commands and retrieves all replies, including command error values.
fn (DB) eval #
fn (mut db DB) eval(script string, keys []string, arguments ...string) !RedisValue
eval executes a Lua script with explicit keys and arguments and preserves its response shape.
fn (DB) eval_ro #
fn (mut db DB) eval_ro(script string, keys []string, arguments ...string) !RedisValue
eval_ro executes a read-only Lua script with explicit keys and arguments.
fn (DB) evalsha #
fn (mut db DB) evalsha(sha string, keys []string, arguments ...string) !RedisValue
evalsha executes a previously loaded Lua script by SHA1 digest.
fn (DB) evalsha_ro #
fn (mut db DB) evalsha_ro(sha string, keys []string, arguments ...string) !RedisValue
evalsha_ro executes a previously loaded read-only script by SHA1 digest.
fn (DB) script_load #
fn (mut db DB) script_load(script string) !string
script_load loads a Lua script into Redis's script cache and returns its SHA1 digest.
fn (DB) script_exists #
fn (mut db DB) script_exists(hashes ...string) ![]bool
script_exists checks script cache membership in digest order.
fn (DB) script_flush #
fn (mut db DB) script_flush(asynchronous bool) !string
script_flush removes all cached scripts; asynchronous selects Redis's ASYNC mode.
fn (DB) script_kill #
fn (mut db DB) script_kill() !string
script_kill interrupts a running script that has not modified the dataset.
fn (DB) script_debug #
fn (mut db DB) script_debug(mode string) !string
script_debug selects Redis's YES, SYNC, or NO Lua debugger mode.
fn (DB) fcall #
fn (mut db DB) fcall(function string, keys []string, arguments ...string) !RedisValue
fcall invokes a registered Redis function with explicit keys and arguments.
fn (DB) fcall_ro #
fn (mut db DB) fcall_ro(function string, keys []string, arguments ...string) !RedisValue
fcall_ro invokes a registered read-only Redis function.
fn (DB) function_load #
fn (mut db DB) function_load(code string, replace bool) !string
function_load loads a Redis function library; replace allows replacing an existing library.
fn (DB) function_delete #
fn (mut db DB) function_delete(library string) !string
function_delete removes a Redis function library.
fn (DB) function_list #
fn (mut db DB) function_list(options ...string) !RedisValue
function_list returns function library metadata, with Redis's optional filter and code arguments.
fn (DB) function_stats #
fn (mut db DB) function_stats() !RedisValue
function_stats returns metadata about the function runtime and executing function.
fn (DB) function_dump #
fn (mut db DB) function_dump() ![]u8
function_dump serializes all registered function libraries for function_restore.
fn (DB) function_restore #
fn (mut db DB) function_restore(data []u8, policy string) !string
function_restore restores serialized function libraries using APPEND, FLUSH, or REPLACE.
fn (DB) function_flush #
fn (mut db DB) function_flush(asynchronous bool) !string
function_flush removes all function libraries; asynchronous selects Redis's ASYNC mode.
fn (DB) function_kill #
fn (mut db DB) function_kill() !string
function_kill interrupts a running function that has not modified the dataset.
fn (DB) info #
fn (mut db DB) info(sections ...string) !string
info returns server information for the requested sections, or the default sections.
fn (DB) config_get #
fn (mut db DB) config_get(patterns ...string) !map[string]string
config_get returns matching configuration names and values under either RESP version.
fn (DB) config_set #
fn (mut db DB) config_set(parameters map[string]string) !string
config_set updates server configuration parameters.
fn (DB) config_rewrite #
fn (mut db DB) config_rewrite() !string
config_rewrite rewrites the server's configuration file with current parameters.
fn (DB) config_resetstat #
fn (mut db DB) config_resetstat() !string
config_resetstat resets server statistics.
fn (DB) client_id #
fn (mut db DB) client_id() !i64
client_id retrieves the current connection's unique client identifier.
fn (DB) client_getname #
fn (mut db DB) client_getname() !string
client_getname retrieves the connection name, or an empty string when unnamed.
fn (DB) client_setname #
fn (mut db DB) client_setname(name string) !string
client_setname assigns a name to the current connection.
fn (DB) client_list #
fn (mut db DB) client_list(filters ...string) !string
client_list returns connected clients, with optional Redis TYPE or ID filters.
fn (DB) client_kill #
fn (mut db DB) client_kill(filters ...string) !RedisValue
client_kill disconnects clients selected by Redis's address or filter arguments. The legacy address form returns a status string; filter arguments return an integer count.
fn (DB) client_pause #
fn (mut db DB) client_pause(milliseconds i64, mode string) !string
client_pause pauses server command processing for the given milliseconds and ALL or WRITE mode.
fn (DB) client_unpause #
fn (mut db DB) client_unpause() !string
client_unpause resumes command processing paused by client_pause.
fn (DB) client_reply #
fn (mut db DB) client_reply(mode string) !string
client_reply configures replies on a dedicated connection using ON, OFF, or SKIP. OFF and SKIP return without reading. Send suppressed commands directly through the transport. Restore ON before using command methods again, or close the dedicated connection afterward.
fn (DB) client_no_touch #
fn (mut db DB) client_no_touch(enabled bool) !string
client_no_touch controls whether reads update key access metadata for this connection.
fn (DB) hello #
fn (mut db DB) hello(version int, options ...string) !RedisValue
hello negotiates a RESP version with optional AUTH or SETNAME arguments. Successful AUTH credentials are restored when reconnecting.
fn (DB) role #
fn (mut db DB) role() !RedisValue
role returns the server's replication role and related metadata.
fn (DB) replicaof #
fn (mut db DB) replicaof(host string, port string) !string
replicaof configures replication, using host NO and port ONE to stop replication.
fn (DB) slaveof #
fn (mut db DB) slaveof(host string, port string) !string
slaveof configures replication using the legacy command; prefer replicaof.
fn (DB) dbsize #
fn (mut db DB) dbsize() !i64
dbsize returns the number of keys in the selected database.
fn (DB) server_time #
fn (mut db DB) server_time() !ServerTime
server_time retrieves Redis's current Unix time with microsecond precision.
fn (DB) flushall #
fn (mut db DB) flushall(asynchronous bool) !string
flushall removes all keys from all databases, optionally in the background.
fn (DB) flushdb #
fn (mut db DB) flushdb(asynchronous bool) !string
flushdb removes all keys from the selected database, optionally in the background.
fn (DB) save #
fn (mut db DB) save() !string
save synchronously saves a snapshot of the database.
fn (DB) bgsave #
fn (mut db DB) bgsave(schedule bool) !string
bgsave starts a background snapshot, optionally scheduling it after an AOF rewrite.
fn (DB) bgrewriteaof #
fn (mut db DB) bgrewriteaof() !string
bgrewriteaof starts a background rewrite of the append-only file.
fn (DB) lastsave #
fn (mut db DB) lastsave() !i64
lastsave retrieves the Unix time of the last successful database snapshot.
fn (DB) monitor #
fn (mut db DB) monitor() !string
monitor starts a command monitoring session on a dedicated connection.
fn (DB) monitor_next #
fn (mut db DB) monitor_next() !string
monitor_next reads the next event from a connection in monitoring mode.
fn (DB) slowlog_get #
fn (mut db DB) slowlog_get(count ...int) !RedisValue
slowlog_get retrieves slow command records, optionally limiting their count.
fn (DB) slowlog_len #
fn (mut db DB) slowlog_len() !i64
slowlog_len returns the number of slow command records.
fn (DB) slowlog_reset #
fn (mut db DB) slowlog_reset() !string
slowlog_reset deletes all slow command records.
fn (DB) swapdb #
fn (mut db DB) swapdb(first int, second int) !string
swapdb exchanges the contents of two logical databases.
fn (DB) memory_usage #
fn (mut db DB) memory_usage(key string, samples ...int) !i64
memory_usage returns a key's memory usage in bytes; a missing key returns an error.
fn (DB) memory_stats #
fn (mut db DB) memory_stats() !RedisValue
memory_stats retrieves memory usage statistics, preserving RESP2 arrays or RESP3 maps.
fn (DB) memory_purge #
fn (mut db DB) memory_purge() !string
memory_purge asks the allocator to release unused memory to the operating system.
fn (DB) memory_malloc_stats #
fn (mut db DB) memory_malloc_stats() !string
memory_malloc_stats returns allocator statistics when supported by the server's allocator.
fn (DB) acl_whoami #
fn (mut db DB) acl_whoami() !string
acl_whoami returns the authenticated user's name.
fn (DB) acl_list #
fn (mut db DB) acl_list() ![]string
acl_list returns ACL rules for all users.
fn (DB) acl_users #
fn (mut db DB) acl_users() ![]string
acl_users returns the names of all configured ACL users.
fn (DB) acl_cat #
fn (mut db DB) acl_cat(category ...string) ![]string
acl_cat lists ACL categories or commands in a specified category.
fn (DB) acl_setuser #
fn (mut db DB) acl_setuser(user string, rules ...string) !string
acl_setuser creates or modifies an ACL user using Redis ACL rule strings.
fn (DB) acl_deluser #
fn (mut db DB) acl_deluser(users ...string) !i64
acl_deluser deletes ACL users and returns the number removed.
fn (DB) acl_getuser #
fn (mut db DB) acl_getuser(user string) !RedisValue
acl_getuser retrieves ACL metadata, or RedisNull for a missing user.
fn (DB) acl_log #
fn (mut db DB) acl_log(options ...string) !RedisValue
acl_log reads ACL security events or resets the log when passed RESET.
fn (DB) acl_dryrun #
fn (mut db DB) acl_dryrun(user string, command ...string) !string
acl_dryrun checks whether a user may execute a command without executing it.
fn (DB) acl_genpass #
fn (mut db DB) acl_genpass(bits ...int) !string
acl_genpass generates a secure password, optionally selecting its number of random bits.
fn (DB) acl_save #
fn (mut db DB) acl_save() !string
acl_save saves configured ACL users to the server's ACL file.
fn (DB) acl_load #
fn (mut db DB) acl_load() !string
acl_load reloads ACL users from the server's ACL file.
fn (DB) quit #
fn (mut db DB) quit() !string
quit closes the server connection after replying OK.
fn (DB) shutdown #
fn (mut db DB) shutdown(options ...string) !
shutdown stops Redis using optional SAVE, NOSAVE, NOW, FORCE, or ABORT arguments. A clean close before any response prefix confirms shutdown; incomplete replies are errors.
fn (DB) command #
fn (mut db DB) command() !RedisValue
command returns metadata for all Redis commands.
fn (DB) command_info #
fn (mut db DB) command_info(commands ...string) !RedisValue
command_info returns metadata for the named Redis commands.
fn (DB) command_count #
fn (mut db DB) command_count() !i64
command_count returns the number of commands supported by Redis.
fn (DB) command_getkeys #
fn (mut db DB) command_getkeys(command ...string) ![]string
command_getkeys extracts key arguments from a command without executing it.
fn (DB) cluster_info #
fn (mut db DB) cluster_info() !string
cluster_info returns cluster state and statistics.
fn (DB) cluster_help #
fn (mut db DB) cluster_help() ![]string
cluster_help returns descriptions of Redis Cluster subcommands.
fn (DB) cluster_nodes #
fn (mut db DB) cluster_nodes() !string
cluster_nodes returns the cluster's node configuration.
fn (DB) cluster_myid #
fn (mut db DB) cluster_myid() !string
cluster_myid returns the current node's cluster identifier.
fn (DB) cluster_slots #
fn (mut db DB) cluster_slots() !RedisValue
cluster_slots returns cluster slot ownership metadata.
fn (DB) cluster_keyslot #
fn (mut db DB) cluster_keyslot(key string) !i64
cluster_keyslot returns the hash slot assigned to a key by Redis Cluster.
fn (DB) cluster_countkeysinslot #
fn (mut db DB) cluster_countkeysinslot(slot int) !i64
cluster_countkeysinslot counts keys assigned to a slot on this cluster node.
fn (DB) cluster_getkeysinslot #
fn (mut db DB) cluster_getkeysinslot(slot int, count int) ![]string
cluster_getkeysinslot retrieves up to count keys assigned to a slot on this node.
fn (DB) xadd #
fn (mut db DB) xadd[T](key string, id string, fields map[string]T, options XAddOptions) !string
xadd appends fields under the given ID ('*' selects a server-generated ID). NOMKSTREAM returns NilError when the stream does not exist.
fn (DB) xread #
fn (mut db DB) xread(streams []StreamOffset, options XReadOptions) ![]StreamRead
xread retrieves entries after each supplied stream ID, optionally blocking for new entries. A timeout or no matching entries returns an empty array.
fn (DB) xreadgroup #
fn (mut db DB) xreadgroup(group string, consumer string, streams []StreamOffset, options XReadOptions) ![]StreamRead
xreadgroup retrieves entries for a group consumer. Use '>' for entries never delivered before.
fn (DB) xgroup_create #
fn (mut db DB) xgroup_create(key string, group string, id string, options XGroupOptions) !string
xgroup_create creates a consumer group starting at the given ID ('0' includes existing entries).
fn (DB) xgroup_createconsumer #
fn (mut db DB) xgroup_createconsumer(key string, group string, consumer string) !bool
xgroup_createconsumer creates a group consumer and reports whether it was newly created.
fn (DB) xgroup_setid #
fn (mut db DB) xgroup_setid(key string, group string, id string, options XGroupOptions) !string
xgroup_setid resets a group's last delivered ID.
fn (DB) xgroup_destroy #
fn (mut db DB) xgroup_destroy(key string, group string) !bool
xgroup_destroy removes a group and reports whether it existed.
fn (DB) xgroup_delconsumer #
fn (mut db DB) xgroup_delconsumer(key string, group string, consumer string) !i64
xgroup_delconsumer removes a consumer and returns its number of pending entries.
fn (DB) xrange #
fn (mut db DB) xrange(key string, start string, end string, options XRangeOptions) ![]StreamEntry
xrange returns entries in ID order between inclusive start and end ('-' and '+' are unbounded).
fn (DB) xrevrange #
fn (mut db DB) xrevrange(key string, end string, start string, options XRangeOptions) ![]StreamEntry
xrevrange returns entries in reverse ID order between inclusive end and start.
fn (DB) xlen #
fn (mut db DB) xlen(key string) !i64
xlen returns the number of entries in a stream.
fn (DB) xdel #
fn (mut db DB) xdel(key string, ids ...string) !i64
xdel deletes entries by ID and returns the number removed.
fn (DB) xtrim #
fn (mut db DB) xtrim(key string, options StreamTrim) !i64
xtrim trims a stream by maximum length or minimum ID and returns the number removed.
fn (DB) xack #
fn (mut db DB) xack(key string, group string, ids ...string) !i64
xack removes delivered IDs from a group's pending list and returns the number acknowledged.
fn (DB) xclaim #
fn (mut db DB) xclaim(key string, group string, consumer string, min_idle_time i64, ids []string, options XClaimOptions) ![]StreamEntry
xclaim transfers ownership of pending entries idle for at least min_idle_time milliseconds.
fn (DB) xclaim_ids #
fn (mut db DB) xclaim_ids(key string, group string, consumer string, min_idle_time i64, ids []string, options XClaimOptions) ![]string
xclaim_ids transfers ownership like xclaim, returning only IDs without increasing delivery counts.
fn (DB) xautoclaim #
fn (mut db DB) xautoclaim(key string, group string, consumer string, min_idle_time i64, start string, options XAutoClaimOptions) !StreamAutoClaim
xautoclaim scans and transfers pending entries, returning the next cursor and claimed records.
fn (DB) xpending #
fn (mut db DB) xpending(key string, group string) !StreamPending
xpending summarizes entries delivered to a consumer group but not yet acknowledged.
fn (DB) xpending_range #
fn (mut db DB) xpending_range(key string, group string, start string, end string, count int, options XPendingOptions) ![]StreamPendingEntry
xpending_range returns pending-entry details in ID order, with optional idle and consumer filters.
fn (DB) xinfo_stream #
fn (mut db DB) xinfo_stream(key string, options XInfoStreamOptions) !map[string]RedisValue
xinfo_stream returns stream metadata as a map, including Redis-version-specific fields.
fn (DB) xinfo_groups #
fn (mut db DB) xinfo_groups(key string) ![]map[string]RedisValue
xinfo_groups returns metadata for each stream consumer group.
fn (DB) xinfo_consumers #
fn (mut db DB) xinfo_consumers(key string, group string) ![]map[string]RedisValue
xinfo_consumers returns metadata for each consumer in a stream group.
fn (DB) multi #
fn (mut db DB) multi() !string
multi starts a transaction. Typed commands return placeholders until exec supplies their results.
fn (DB) exec #
fn (mut db DB) exec() ![]RedisValue
exec executes queued transaction commands. Aborted WATCH transactions return NilError. Individual command errors remain RedisBlobError values in the returned result array.
fn (DB) discard #
fn (mut db DB) discard() !string
discard cancels a transaction, including a transaction buffered by transaction_start.
fn (DB) watch #
fn (mut db DB) watch(keys ...string) !string
watch makes exec abort if any watched key changes before the transaction executes.
fn (DB) unwatch #
fn (mut db DB) unwatch() !string
unwatch removes all watched keys from this connection.
fn (DB) transaction_start #
fn (mut db DB) transaction_start() !
transaction_start buffers MULTI and subsequent commands for execution in one write. Call watch before this method when optimistic locking is needed.
fn (DB) transaction_execute #
fn (mut db DB) transaction_execute() ![]RedisValue
transaction_execute sends a buffered transaction and returns its EXEC results. It consumes all intermediate replies, preserving synchronization after command errors.
struct GeoAddOptions #
struct GeoAddOptions {
pub:
mode GeoAddMode
changed bool
}
GeoAddOptions configures conditional updates and counting of changed members.
struct GeoMember #
struct GeoMember {
pub:
name string
longitude f64
latitude f64
}
GeoMember associates a member name with a geographic position.
struct GeoPosition #
struct GeoPosition {
pub:
longitude f64
latitude f64
}
GeoPosition is a longitude and latitude pair in degrees.
struct GeoSearchOptions #
struct GeoSearchOptions {
pub:
from_member ?string
longitude f64
latitude f64
radius f64
width f64
height f64
unit GeoUnit = .m
order GeoOrder
count int
any bool
with_dist bool
with_hash bool
with_coord bool
}
GeoSearchOptions selects a circle or box centered on a member or longitude/latitude. Use radius for a circle, or width and height for a box. Optional result fields are explicit.
struct GeoSearchResult #
struct GeoSearchResult {
pub:
member string
distance ?f64
hash ?i64
position ?GeoPosition
}
GeoSearchResult contains a member and the optional metadata requested by a search.
struct GetExOptions #
struct GetExOptions {
pub:
mode GetExMode
value i64
}
GetExOptions configures getex expiration in seconds, milliseconds, or Unix timestamps.
struct ListPop #
struct ListPop {
pub:
key string
values []string
}
ListPop contains the source key and the elements returned by a blocking or multi-key pop.
struct Metrics #
struct Metrics {
pub mut:
commands u64
failures u64
reconnects u64
duration time.Duration
}
Metrics records completed commands, failures, reconnects, and total command time.
struct NilError #
struct NilError {
pub:
message string
}
NilError represents a missing value or aborted transaction.
fn (NilError) msg #
fn (e NilError) msg() string
msg returns the error message.
fn (NilError) code #
fn (e NilError) code() int
code returns the Redis client error category.
struct ProtocolError #
struct ProtocolError {
pub:
message string
}
ProtocolError represents an invalid RESP frame or reply shape.
fn (ProtocolError) msg #
fn (e ProtocolError) msg() string
msg returns the error message.
fn (ProtocolError) code #
fn (e ProtocolError) code() int
code returns the Redis client error category.
struct PubSub #
struct PubSub {
mut:
db DB
channels []string
patterns []string
pending []PubSubMessage
}
PubSub owns a dedicated connection. Use a separate DB for commands and publishing. Its methods must not be called concurrently on the same connection.
fn (PubSub) close #
fn (mut sub PubSub) close() !
close terminates the dedicated subscription connection.
fn (PubSub) subscribe #
fn (mut sub PubSub) subscribe(channels ...string) !
subscribe subscribes to channels and consumes their acknowledgments before returning.
fn (PubSub) psubscribe #
fn (mut sub PubSub) psubscribe(patterns ...string) !
psubscribe subscribes to glob patterns and consumes their acknowledgments before returning.
fn (PubSub) unsubscribe #
fn (mut sub PubSub) unsubscribe(channels ...string) !
unsubscribe removes channel subscriptions. With no arguments, it removes all channels.
fn (PubSub) punsubscribe #
fn (mut sub PubSub) punsubscribe(patterns ...string) !
punsubscribe removes pattern subscriptions. With no arguments, it removes all patterns.
fn (PubSub) next_message #
fn (mut sub PubSub) next_message() !PubSubMessage
next_message waits for a published message, skipping subscription acknowledgments. The configured read timeout also applies to this blocking call.
fn (PubSub) listen #
fn (mut sub PubSub) listen(callback fn (PubSubMessage) bool) !
listen invokes callback for each message until callback returns false.
fn (PubSub) subscribe_with_callback #
fn (mut sub PubSub) subscribe_with_callback(channels []string, callback fn (PubSubMessage) bool) !
subscribe_with_callback subscribes to channels and processes messages until callback returns false.
fn (PubSub) psubscribe_with_callback #
fn (mut sub PubSub) psubscribe_with_callback(patterns []string, callback fn (PubSubMessage) bool) !
psubscribe_with_callback subscribes to patterns and processes messages until callback returns false.
struct PubSubMessage #
struct PubSubMessage {
pub:
channel string
pattern string
payload []u8
}
PubSubMessage is a binary-safe published message. Pattern is set for pattern subscriptions.
struct RedisBlobError #
struct RedisBlobError {
pub:
data []u8
}
RESP3 wrapper types
struct RedisMap #
struct RedisMap {
pub:
// interleaved key/value pairs: [k1, v1, k2, v2, ...]
pairs []RedisValue
}
struct RedisNull #
struct RedisNull {}
RedisNull represents the Redis NULL type
struct RedisPush #
struct RedisPush {
pub:
elements []RedisValue
}
struct RedisSet #
struct RedisSet {
pub:
elements []RedisValue
}
struct RedisVerbatim #
struct RedisVerbatim {
pub:
format string
data []u8
}
struct ScanOptions #
struct ScanOptions {
pub:
match ?string
count int
}
ScanOptions configures optional pattern matching and the suggested scan batch size.
struct Sentinel #
struct Sentinel {
mut:
config SentinelConfig
db DB
}
Sentinel owns a discovered master connection and can rediscover it after failover.
fn (Sentinel) reconnect #
fn (mut client Sentinel) reconnect() !
reconnect reconsults Sentinel and replaces the connection to the current master.
fn (Sentinel) cmd #
fn (mut client Sentinel) cmd(args ...string) !RedisValue
cmd executes on the discovered master. READONLY replies trigger discovery and one safe retry. Transport failures rediscover for the next call, but the failed command is not replayed.
fn (Sentinel) close #
fn (mut client Sentinel) close() !
close closes the current master connection.
struct SentinelConfig #
struct SentinelConfig {
pub:
sentinels []Config
master_name string
master_config Config
}
SentinelConfig separates Sentinel credentials from the discovered master's connection settings.
struct ServerTime #
struct ServerTime {
pub:
seconds i64
microseconds i64
}
ServerTime is Redis's Unix timestamp with microsecond precision.
struct StreamAutoClaim #
struct StreamAutoClaim {
pub:
cursor string
entries []StreamEntry
ids []string
deleted_ids []string
}
StreamAutoClaim contains the next cursor, claimed entries or IDs, and deleted pending IDs. Redis versions before 7.0 omit deleted_ids. With justid, only ids is populated.
struct StreamEntry #
struct StreamEntry {
pub:
id string
fields map[string]string
deleted bool
}
StreamEntry is one stream record. Fields preserve arbitrary binary data in V strings. Deleted records read from a group's pending list have deleted set to true.
struct StreamOffset #
struct StreamOffset {
pub:
key string
id string
}
StreamOffset identifies a stream and the last seen ID, or a special ID such as '$' or '>'.
struct StreamPending #
struct StreamPending {
pub:
count i64
smallest ?string
largest ?string
consumers []StreamPendingConsumer
}
StreamPending summarizes a consumer group's pending entry list.
struct StreamPendingConsumer #
struct StreamPendingConsumer {
pub:
consumer string
count i64
}
StreamPendingConsumer reports how many pending entries belong to a consumer.
struct StreamPendingEntry #
struct StreamPendingEntry {
pub:
id string
consumer string
idle_ms i64
deliveries i64
}
StreamPendingEntry describes the owner, idle duration and delivery count of one pending entry.
struct StreamRead #
struct StreamRead {
pub:
key string
entries []StreamEntry
}
StreamRead contains the entries returned for one stream by xread or xreadgroup.
struct StreamTrim #
struct StreamTrim {
pub:
maxlen ?i64
minid ?string
approximate bool
limit i64
}
StreamTrim configures trimming by maximum length or minimum ID. Set exactly one of maxlen and minid; limit is valid only with approximate trimming.
struct WeightedKey #
struct WeightedKey {
pub:
key string
weight f64 = 1.0
}
WeightedKey selects a sorted set and the multiplier applied to its scores.
struct XAddOptions #
struct XAddOptions {
pub:
nomkstream bool
trim StreamTrim
}
XAddOptions configures optional stream creation and trimming during xadd.
struct XAutoClaimOptions #
struct XAutoClaimOptions {
pub:
count int
justid bool
}
XAutoClaimOptions configures automatic pending-entry ownership transfer.
struct XClaimOptions #
struct XClaimOptions {
pub:
idle ?i64
time ?i64
retrycount ?i64
force bool
lastid ?string
}
XClaimOptions configures ownership transfer for pending stream entries.
struct XGroupOptions #
struct XGroupOptions {
pub:
mkstream bool // only valid for xgroup_create
entries_read ?i64 // Redis 7.0 or newer
}
XGroupOptions configures creation or resetting of a group's last delivered ID.
struct XInfoStreamOptions #
struct XInfoStreamOptions {
pub:
full bool
count int
}
XInfoStreamOptions requests full stream/group metadata and limits its record count.
struct XPendingOptions #
struct XPendingOptions {
pub:
idle ?i64
consumer ?string
}
XPendingOptions filters extended pending-entry queries by idle time and consumer.
struct XRangeOptions #
struct XRangeOptions {
pub:
count int
}
XRangeOptions limits the number of records returned by a stream range command.
struct XReadOptions #
struct XReadOptions {
pub:
count int
block ?i64
noack bool // only valid for xreadgroup
}
XReadOptions configures a read count and blocking timeout in milliseconds. An omitted block does not block; block: 0 waits indefinitely.
struct ZAddOptions #
struct ZAddOptions {
pub:
nx bool
xx bool
gt bool
lt bool
changed bool
}
ZAddOptions configures conditional updates and whether zadd counts changed members.
struct ZCombineOptions #
struct ZCombineOptions {
pub:
aggregate ZAggregate
}
ZCombineOptions configures score aggregation in sorted set union and intersection.
struct ZMember #
struct ZMember {
pub:
member string
score f64
}
ZMember contains a sorted set member and its score.
struct ZPop #
struct ZPop {
pub:
key string
value ZMember
}
ZPop contains the source key and sorted set member returned by a blocking pop.
struct ZRangeLimit #
struct ZRangeLimit {
pub:
offset i64
count ?i64
}
ZRangeLimit configures an optional LIMIT for score or lexicographic ranges.
struct ZRangeOptions #
struct ZRangeOptions {
pub:
rev bool
}
ZRangeOptions configures the direction of a rank-based sorted set range.
- README
- fn async_client
- fn connect
- fn connect_cluster
- fn connect_pubsub
- fn connect_sentinel
- fn hash_slot
- interface Redis
- interface RedisError
- type RedisValue
- enum BitFieldKind
- enum BitOperation
- enum BitOverflow
- enum BitUnit
- enum GeoAddMode
- enum GeoOrder
- enum GeoUnit
- enum GetExMode
- enum ListInsertPosition
- enum ListSide
- enum ZAggregate
- struct AsyncClient
- struct AsyncResult
- struct AuthError
- struct BitFieldOperation
- struct BitRange
- struct Cluster
- struct CommandError
- struct CommandTrace
- struct Config
- struct ConnectionError
- struct DB
- fn setbit
- fn getbit
- fn bitcount
- fn bitpos
- fn bitop
- fn bitfield
- fn bitfield_ro
- fn pfadd
- fn pfcount
- fn pfmerge
- fn mget
- fn mset
- fn msetnx
- fn setnx
- fn setex
- fn psetex
- fn getdel
- fn getex
- fn incrby
- fn decrby
- fn incrbyfloat
- fn exists
- fn ttl
- fn pttl
- fn pexpire
- fn expireat
- fn pexpireat
- fn persist
- fn unlink
- fn keys
- fn scan
- fn key_type
- fn rename
- fn hdel
- fn hexists
- fn hkeys
- fn hvals
- fn hlen
- fn hstrlen
- fn hsetnx
- fn hincrby
- fn hincrbyfloat
- fn hmget
- fn hscan
- fn append
- fn strlen
- fn getrange
- fn setrange
- fn statistics
- fn reconnect
- fn select_db
- fn lpush
- fn rpush
- fn lpushx
- fn rpushx
- fn lpop
- fn rpop
- fn lpop_count
- fn rpop_count
- fn rpoplpush
- fn llen
- fn lrange
- fn lindex
- fn lset
- fn ltrim
- fn linsert
- fn lrem
- fn lpos
- fn blpop
- fn brpop
- fn lmove
- fn blmove
- fn lmpop
- fn blmpop
- fn sadd
- fn srem
- fn smembers
- fn sismember
- fn smismember
- fn scard
- fn spop
- fn spop_count
- fn srandmember
- fn srandmember_count
- fn smove
- fn sinter
- fn sinterstore
- fn sintercard
- fn sunion
- fn sunionstore
- fn sdiff
- fn sdiffstore
- fn sscan
- fn zadd
- fn zadd_with_options
- fn zrem
- fn zcard
- fn zcount
- fn zscore
- fn zmscore
- fn zincrby
- fn zrank
- fn zrevrank
- fn zrange
- fn zrange_withscores
- fn zrevrange
- fn zrevrange_withscores
- fn zrangebyscore
- fn zrangebyscore_withscores
- fn zrangebylex
- fn zpopmax
- fn zpopmin
- fn bzpopmax
- fn bzpopmin
- fn zrandmember
- fn zrandmember_count
- fn zrandmember_withscores
- fn zdiff
- fn zdiff_withscores
- fn zdiffstore
- fn zinter
- fn zinter_withscores
- fn zinterstore
- fn zunion
- fn zunion_withscores
- fn zunionstore
- fn zintercard
- fn zlexcount
- fn zremrangebyrank
- fn zremrangebyscore
- fn zremrangebylex
- fn zscan
- fn geoadd
- fn geodist
- fn geohash
- fn geopos
- fn geosearch
- fn geosearchstore
- fn georadius
- fn georadiusbymember
- fn publish
- fn close
- fn auth
- fn auth_user
- fn ping
- fn validate
- fn reset
- fn del
- fn set
- fn get
- fn incr
- fn decr
- fn hset
- fn hget
- fn hgetall
- fn expire
- fn cmd
- fn pipeline_start
- fn pipeline_execute
- fn eval
- fn eval_ro
- fn evalsha
- fn evalsha_ro
- fn script_load
- fn script_exists
- fn script_flush
- fn script_kill
- fn script_debug
- fn fcall
- fn fcall_ro
- fn function_load
- fn function_delete
- fn function_list
- fn function_stats
- fn function_dump
- fn function_restore
- fn function_flush
- fn function_kill
- fn info
- fn config_get
- fn config_set
- fn config_rewrite
- fn config_resetstat
- fn client_id
- fn client_getname
- fn client_setname
- fn client_list
- fn client_kill
- fn client_pause
- fn client_unpause
- fn client_reply
- fn client_no_touch
- fn hello
- fn role
- fn replicaof
- fn slaveof
- fn dbsize
- fn server_time
- fn flushall
- fn flushdb
- fn save
- fn bgsave
- fn bgrewriteaof
- fn lastsave
- fn monitor
- fn monitor_next
- fn slowlog_get
- fn slowlog_len
- fn slowlog_reset
- fn swapdb
- fn memory_usage
- fn memory_stats
- fn memory_purge
- fn memory_malloc_stats
- fn acl_whoami
- fn acl_list
- fn acl_users
- fn acl_cat
- fn acl_setuser
- fn acl_deluser
- fn acl_getuser
- fn acl_log
- fn acl_dryrun
- fn acl_genpass
- fn acl_save
- fn acl_load
- fn quit
- fn shutdown
- fn command
- fn command_info
- fn command_count
- fn command_getkeys
- fn cluster_info
- fn cluster_help
- fn cluster_nodes
- fn cluster_myid
- fn cluster_slots
- fn cluster_keyslot
- fn cluster_countkeysinslot
- fn cluster_getkeysinslot
- fn xadd
- fn xread
- fn xreadgroup
- fn xgroup_create
- fn xgroup_createconsumer
- fn xgroup_setid
- fn xgroup_destroy
- fn xgroup_delconsumer
- fn xrange
- fn xrevrange
- fn xlen
- fn xdel
- fn xtrim
- fn xack
- fn xclaim
- fn xclaim_ids
- fn xautoclaim
- fn xpending
- fn xpending_range
- fn xinfo_stream
- fn xinfo_groups
- fn xinfo_consumers
- fn multi
- fn exec
- fn discard
- fn watch
- fn unwatch
- fn transaction_start
- fn transaction_execute
- struct GeoAddOptions
- struct GeoMember
- struct GeoPosition
- struct GeoSearchOptions
- struct GeoSearchResult
- struct GetExOptions
- struct ListPop
- struct Metrics
- struct NilError
- struct ProtocolError
- struct PubSub
- struct PubSubMessage
- struct RedisBlobError
- struct RedisMap
- struct RedisNull
- struct RedisPush
- struct RedisSet
- struct RedisVerbatim
- struct ScanOptions
- struct Sentinel
- struct SentinelConfig
- struct ServerTime
- struct StreamAutoClaim
- struct StreamEntry
- struct StreamOffset
- struct StreamPending
- struct StreamPendingConsumer
- struct StreamPendingEntry
- struct StreamRead
- struct StreamTrim
- struct WeightedKey
- struct XAddOptions
- struct XAutoClaimOptions
- struct XClaimOptions
- struct XGroupOptions
- struct XInfoStreamOptions
- struct XPendingOptions
- struct XRangeOptions
- struct XReadOptions
- struct ZAddOptions
- struct ZCombineOptions
- struct ZMember
- struct ZPop
- struct ZRangeLimit
- struct ZRangeOptions