RESP3-based Redis client library for the Odin programming language.
- RESP3
- Basic connection pooling with configurable min/max connections
- Flat Client API — all Redis commands as methods on a single
Clientstruct. Might change later. - Type-safe responses — native Odin types (
string,i64,bool, etc.)
package main
import "redonis"
main :: proc() {
cfg := redonis.Pool_Config{
address = "localhost:6379",
password = "", // optional
username = "", // optional (Redis 6+ ACL)
database = 0, // optional
min_conns = 0,
max_conns = 10,
}
client, err := redonis.client_init(cfg)
defer redonis.client_destroy(client)
// Strings
redonis.client_set(client, "key", "value")
val, _ := redonis.client_get(client, "key")
// Hashes
redonis.client_hset(client, "hash", "field1", "val1", "field2", "val2")
hval, _ := redonis.client_hget(client, "hash", "field1")
// Lists
redonis.client_lpush(client, "list", "a", "b", "c")
items, _ := redonis.client_lrange(client, "list", 0, -1)
// Sets
redonis.client_sadd(client, "set", "x", "y", "z")
members, _ := redonis.client_smembers(client, "set")
// Sorted Sets
redonis.client_zadd(client, "zset", .None, "1.0", "one", "2.0", "two")
// Streams
redonis.client_xadd(client, "stream", "*", "sensor", "temp", "value", "42")
// Raw execute for custom/unimplemented commands
raw_val, _ := redonis.client_raw(client, "CUSTOM", "arg1", "arg2")
}Errors are a tagged union:
Error :: union {
Redis_Error, // Redis returned an error (code + message)
Connection_Error, // Dial, connection lost, auth/hello failed, parse error
Pool_Error, // Pool exhausted or closed
}Usage:
val, err := redonis.client_get(client, "key")
switch e in err {
case redonis.Redis_Error:
fmt.println("Redis error:", e.code, e.message)
case redonis.Connection_Error:
fmt.println("Connection error:", e)
case redonis.Pool_Error:
fmt.println("Pool error:", e)
}ping echo select quit hello
info time client_list client_getname client_setname config_get config_set command
del exists expire expireat ttl pttl persist keys scan type rename renamenx dbsize flushdb flushall randomkey move copy
set set_ex set_px set_nx set_xx get getset mget mset setnx setex psetex append strlen incr incrby decr decrby incrbyfloat getrange setrange getdel getex
hset hsetnx hget hgetall hdel hexists hkeys hvals hlen hincrby hincrbyfloat hmget hmset hscan
lpush rpush lpop rpop llen lrange lindex lset lrem ltrim blpop brpop linsert lpos
sadd srem smembers sismember scard spop srandmember smove sunion sunionstore sinter sinterstore sdiff sdiffstore sscan smismember
zadd zrem zscore zrank zrevrank zcard zcount zrange zrevrange zrangebyscore zincrby zremrangebyrank zremrangebyscore zpopmin zpopmax zscan
xadd xread xrange xrevrange xlen xdel xtrim xreadgroup xgroup_create xgroup_destroy xgroup_createconsumer xgroup_delconsumer xack xclaim xpending
geoadd geodist geohash geopos geosearch geosearchstore
pfadd pfcount pfmerge
setbit getbit bitcount bitpos bitop bitfield
eval evalsha script_load script_exists script_flush script_kill
multi exec discard watch unwatch
acl_list acl_users acl_getuser acl_setuser acl_deluser acl_cat acl_genpass acl_whoami acl_log acl_save acl_load acl_dryrun
touch unlink sort
client_raw — execute any Redis command by passing args directly. Useful for commands not yet wrapped.
subscribe unsubscribe psubscribe punsubscribe publish pubsub
The connection layer already has conn_send/conn_receive split and conn_receive_push for reading push messages. Pub/Sub will be added in v2 with a background thread for push message dispatch and a callback/subscription registry on the Client.
All CLUSTER * commands (e.g., CLUSTER NODES, CLUSTER SLOTS, CLUSTER MEET, etc.)
Batch command execution (pipeline_queue / pipeline_exec).
- Idle connection timeout/eviction
- Health checks (periodic PING)
- Connection max lifetime
- Metrics (active/idle count)
- No integration tests against a running Redis instance yet
- No unit tests for the RESP3 parser/writer
- I've no idea how to handle package versioning in odin. I need to do some research.