You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A high-performance, Redis-compatible in-memory data store written in Zig.
Overview
Zoltraak is a modern alternative to Redis, built from the ground up using the Zig programming language. It aims to provide Redis compatibility while leveraging Zig's performance characteristics, memory safety, and simplicity.
Goals
Redis Protocol Compatibility: Full RESP (Redis Serialization Protocol) support for drop-in replacement
High Performance: Leverage Zig's zero-overhead abstractions and manual memory control
Memory Efficiency: Predictable memory usage with no garbage collection pauses
Simplicity: Clean, auditable codebase with minimal dependencies
Cross-Platform: Native support for Linux, macOS, and Windows
Planned Features
Data Structures
Strings
Lists
Sets
Hashes
Sorted Sets
Core Functionality
Key expiration (TTL)
Pub/Sub messaging
Transactions (MULTI/EXEC/DISCARD/WATCH/UNWATCH)
Persistence (RDB snapshots, AOF logging)
Replication
Requirements
Zig 0.15.0 or later
Building
# Build the project
zig build
# Run all tests (unit + integration)
zig build test# Run only integration tests
zig build test-integration
# Build in release mode
zig build -Doptimize=ReleaseFast
Usage
# Start the server (default: 127.0.0.1:6379)
./zig-out/bin/zoltraak
# Start with custom host/port
./zig-out/bin/zoltraak --host 0.0.0.0 --port 6380
# Connect using redis-cli
redis-cli -p 6379
# Use zoltraak-cli for interactive REPL
./zig-out/bin/zoltraak-cli
# Launch TUI key browser
./zig-out/bin/zoltraak-cli --tui
# Launch advanced TUI with Tree/LineChart/Dialog/Notification widgets (sailor v0.5.0+)
./zig-out/bin/zoltraak-cli --tui --advanced
Supported Commands
String Commands (Iterations 1, 19, 45-47)
Command
Syntax
Description
PING
PING [message]
Test connectivity
SET
SET key value [EX s] [PX ms] [NX|XX]
Set key-value with optional TTL
GET
GET key
Get value by key
DEL
DEL key [key ...]
Delete one or more keys
EXISTS
EXISTS key [key ...]
Check if keys exist
INCR
INCR key
Increment integer value by 1
DECR
DECR key
Decrement integer value by 1
INCRBY
INCRBY key increment
Increment integer value by increment
DECRBY
DECRBY key decrement
Decrement integer value by decrement
INCRBYFLOAT
INCRBYFLOAT key increment
Increment float value by increment
APPEND
APPEND key value
Append value to string, returns new length
STRLEN
STRLEN key
Get length of string value
GETSET
GETSET key value
Set value and return old value
GETDEL
GETDEL key
Get value and delete key
GETEX
GETEX key [EX s|PX ms|EXAT ts|PXAT ts|PERSIST]
Get value and optionally update expiry
SETNX
SETNX key value
Set value only if key does not exist
SETEX
SETEX key seconds value
Set value with expiry in seconds
PSETEX
PSETEX key milliseconds value
Set value with expiry in milliseconds
MGET
MGET key [key ...]
Get values of multiple keys
MSET
MSET key value [key value ...]
Set multiple keys to multiple values
MSETNX
MSETNX key value [key value ...]
Set multiple keys only if none exist
MSETEX
MSETEX numkeys key value [key value ...] [NX|XX] [EX seconds|PX ms|EXAT ts|PXAT ts|KEEPTTL]
Atomically set multiple keys with optional shared expiration (returns 1 if all set, 0 otherwise)
LCS
LCS key1 key2 [LEN]
Find the longest common subsequence between two strings (returns LCS string by default, length with LEN option)
List Commands (Iterations 2, 11, 18, 49)
Command
Syntax
Description
LPUSH
LPUSH key element [element ...]
Push elements to list head
RPUSH
RPUSH key element [element ...]
Push elements to list tail
LPOP
LPOP key [count]
Pop elements from list head
RPOP
RPOP key [count]
Pop elements from list tail
LRANGE
LRANGE key start stop
Get range of elements
LLEN
LLEN key
Get list length
LINDEX
LINDEX key index
Get element at index
LSET
LSET key index element
Set element at index
LTRIM
LTRIM key start stop
Trim list to range
LREM
LREM key count element
Remove elements by value
LPUSHX
LPUSHX key element [element ...]
Push to head if key exists
RPUSHX
RPUSHX key element [element ...]
Push to tail if key exists
LINSERT
LINSERT key BEFORE|AFTER pivot element
Insert before/after pivot
LPOS
LPOS key element [RANK rank] [COUNT num] [MAXLEN len]
Protocol negotiation command - negotiates RESP2/RESP3 protocol version per connection, returns server information in negotiated format (map for RESP3, array for RESP2)
HGETALL: Returns RESP3 map (%<count>\r\n<key><value>...\r\n) when RESP3 is negotiated, RESP2 array otherwise
SMEMBERS: Returns RESP3 set (~<count>\r\n<elem>...\r\n) when RESP3 is negotiated, RESP2 array otherwise
HKEYS: Returns RESP3 set when RESP3 is negotiated (field names are unique), RESP2 array otherwise
ZRANGE with WITHSCORES: Returns RESP3 map (member → score) when RESP3 is negotiated, RESP2 flat array otherwise
ZREVRANGE with WITHSCORES: Returns RESP3 map (member → score) when RESP3 is negotiated, RESP2 flat array otherwise
SINTER: Returns RESP3 set when RESP3 is negotiated, RESP2 array otherwise
SUNION: Returns RESP3 set when RESP3 is negotiated, RESP2 array otherwise
SDIFF: Returns RESP3 set when RESP3 is negotiated, RESP2 array otherwise
Protocol version is tracked per connection and persists for the session duration
All other commands continue to work with both RESP2 and RESP3
Scripting Commands (Iteration 36)
Command
Syntax
Description
EVAL
EVAL script numkeys key [key ...] arg [arg ...]
Execute a Lua script server side (stub implementation - returns nil)
EVALSHA
EVALSHA sha1 numkeys key [key ...] arg [arg ...]
Execute a cached script by SHA1 digest (stub implementation - returns nil)
SCRIPT LOAD
SCRIPT LOAD script
Load a script into the script cache and return its SHA1 digest
SCRIPT EXISTS
SCRIPT EXISTS sha1 [sha1 ...]
Check if scripts exist in the cache (returns array of 1/0)
SCRIPT FLUSH
SCRIPT FLUSH [ASYNC|SYNC]
Remove all scripts from the script cache
SCRIPT HELP
SCRIPT HELP
Show help for SCRIPT command
Note: The scripting commands provide Redis-compatible interfaces but currently return stub values (nil for EVAL/EVALSHA). Full Lua script execution would require embedding a Lua interpreter. The SCRIPT LOAD command generates proper SHA1 hashes and stores scripts for future reference.
ACL (Access Control List) Commands (Iteration 37)
Command
Syntax
Description
ACL WHOAMI
ACL WHOAMI
Return the current connection username (stub: always returns "default")
ACL LIST
ACL LIST
List all ACL rules in config file format (stub: only default user)
ACL USERS
ACL USERS
List all usernames (stub: only "default" exists)
ACL GETUSER
ACL GETUSER <username>
Get user details including flags, passwords, commands, and keys (stub: only default user supported)
Create or modify user with specified attributes (stub: accepts but doesn't persist)
ACL DELUSER
ACL DELUSER <username> [<username> ...]
Delete one or more users (stub: cannot delete default user)
ACL CAT
ACL CAT [<category>]
List command categories or commands in a category
ACL HELP
ACL HELP
Show help for ACL command
Note: The ACL commands provide Redis-compatible interfaces but are stub implementations. Authentication and authorization are not enforced - all clients have full access. The commands return appropriate responses for compatibility with Redis clients but do not store or enforce user permissions.
CLUSTER Commands (Iteration 38)
Command
Syntax
Description
CLUSTER SLOTS
CLUSTER SLOTS
Return cluster slots configuration (stub: single node covering all 16384 slots)
CLUSTER NODES
CLUSTER NODES
Return cluster nodes configuration (stub: single standalone node)
CLUSTER INFO
CLUSTER INFO
Return cluster state information (stub: reports cluster as ok with 1 node)
CLUSTER MYID
CLUSTER MYID
Return the node ID (stub: returns "zoltraak-standalone-node")
CLUSTER KEYSLOT
CLUSTER KEYSLOT <key>
Return hash slot (0-16383) for a key using CRC16 algorithm
CLUSTER COUNTKEYSINSLOT
CLUSTER COUNTKEYSINSLOT <slot>
Count keys in a hash slot (stub: always returns 0)
CLUSTER GETKEYSINSLOT
CLUSTER GETKEYSINSLOT <slot> <count>
Return keys in a hash slot (stub: always returns empty array)
CLUSTER HELP
CLUSTER HELP
Show help for CLUSTER command
Note: The CLUSTER commands provide Redis-compatible interfaces for cluster mode, but Zoltraak operates as a single standalone node. Most commands return stub values indicating a single-node cluster. CLUSTER KEYSLOT correctly implements the Redis CRC16 hash slot algorithm with hash tag support (e.g., {foo}bar uses "foo" for hashing), which is useful for understanding key distribution even in standalone mode.
Utility Commands (Iterations 39-41)
Command
Syntax
Description
ECHO
ECHO message
Returns the given message
QUIT
QUIT
Close the connection (returns OK then server closes connection)
SELECT
SELECT index
Select the database by index (only DB 0 supported, single-database mode)
SWAPDB
SWAPDB index1 index2
Swap two databases (stub: only SWAPDB 0 0 supported in single-database mode)
TIME
TIME
Returns the current Unix timestamp in seconds and microseconds
LASTSAVE
LASTSAVE
Returns Unix timestamp of the last successful RDB save to disk
MONITOR
MONITOR
Enable real-time command monitoring (stub: returns OK, monitoring not implemented)
DEBUG OBJECT
DEBUG OBJECT key
Show low-level info about key and associated value
Note: MONITOR and SHUTDOWN are stub implementations that return OK for Redis compatibility but do not perform actual monitoring or shutdown operations. SELECT only accepts database index 0 (Zoltraak uses a single-database architecture). SWAPDB is a stub that only accepts swapping database 0 with itself (a no-op).
Iteration 28: 2 stream consumer group recovery commands (XCLAIM, XAUTOCLAIM) - claim ownership of pending messages and transfer between consumers
Iteration 29: 7 server introspection commands (MEMORY STATS/USAGE/DOCTOR/HELP, SLOWLOG GET/LEN/RESET) - server monitoring and debugging tools (stub implementations)
Iteration 30: Comprehensive INFO command - complete implementation with all major sections (Server, Clients, Memory, Persistence, Stats, Replication, CPU, Keyspace)
Iteration 31: RESP3 protocol support - parser and writer for RESP3 types (null, boolean, double, big number, bulk error, verbatim string, map, set, push), HELLO command for protocol negotiation (basic RESP2 implementation)
Iteration 32: Full RESP3 integration - per-connection protocol tracking, HELLO command negotiates and persists protocol version (RESP2 or RESP3), responses formatted according to negotiated protocol
Iteration 33: Protocol-aware response formatting - HGETALL returns RESP3 map when RESP3 negotiated, SMEMBERS returns RESP3 set when RESP3 negotiated, leveraging native RESP3 collection types for better semantic clarity
Iteration 34: Extended RESP3-aware commands - HKEYS returns RESP3 set (field names are unique), ZRANGE/ZREVRANGE with WITHSCORES return RESP3 map (member → score), expanding native RESP3 type usage for improved semantic clarity
Iteration 35: Set operation RESP3 support - SINTER/SUNION/SDIFF return RESP3 set when RESP3 negotiated, completing RESP3 native type usage for all set-returning commands
Iteration 36: Basic scripting support - EVAL, EVALSHA, SCRIPT LOAD/EXISTS/FLUSH/HELP commands with SHA1 script caching (stub implementation - returns nil, full Lua execution pending)
Iteration 38: CLUSTER basic stubs - CLUSTER SLOTS/NODES/INFO/MYID/KEYSLOT/COUNTKEYSINSLOT/GETKEYSINSLOT/HELP commands (stub implementation - single standalone node, KEYSLOT implements full CRC16 hash slot algorithm with hash tag support)
Iteration 39: Utility commands - ECHO, QUIT, TIME, LASTSAVE, MONITOR, DEBUG (OBJECT, HELP), SHUTDOWN commands for server management and debugging (MONITOR and SHUTDOWN are stubs)
Iteration 40: SELECT command - database selection (single-database mode, only DB 0 supported for Redis client compatibility)
Iteration 41: SWAPDB command - database swapping (stub implementation - single-database mode, only SWAPDB 0 0 supported as no-op)
Iteration 42: Advanced sorted set operations and hash string length - ZUNION/ZINTER/ZDIFF (set-like operations on sorted sets with score aggregation), ZUNIONSTORE/ZINTERSTORE/ZDIFFSTORE (store results), HSTRLEN (hash field value string length)
Iteration 43: Sorted set range removal and lexicographical operations - ZREMRANGEBYRANK/ZREMRANGEBYSCORE/ZREMRANGEBYLEX (range deletion by rank/score/lex), ZRANGEBYLEX/ZREVRANGEBYLEX (lexicographical range queries for equal-score members), ZLEXCOUNT (count members in lex range)
Iteration 44: Bitfield operations - BITFIELD (arbitrary bitfield integer operations with GET/SET/INCRBY and WRAP/SAT/FAIL overflow modes), BITFIELD_RO (read-only variant) - supports signed and unsigned integers from 1 to 64 bits
Iteration 45: LCS (Longest Common Subsequence) command - LCS key1 key2 [LEN] for string comparison, returns the longest common subsequence string or its length
Iteration 46: LCS IDX mode - LCS key1 key2 IDX [MINMATCHLEN len] [WITHMATCHLEN] returns match positions as arrays with "matches" (key1_range, key2_range, optional match_len) and "len" keys
Iteration 47: MSETEX command - MSETEX numkeys key value [key value ...] [NX|XX] [EX/PX/EXAT/PXAT/KEEPTTL] atomically sets multiple keys with optional shared expiration (new Redis 8.4+ command)
Iteration 48: HRANDFIELD command - HRANDFIELD key [count [WITHVALUES]] returns random field(s) from hash (single field without count, array with count, field-value pairs with WITHVALUES, RESP3 map support)
Iteration 49: Multi-pop commands (Redis 7.0+) - LMPOP (non-blocking list multi-pop), ZMPOP (sorted set multi-pop with MIN/MAX), BZMPOP (blocking sorted set multi-pop) - unified pop operations from multiple keys
Iteration 50: Hash field-level TTL commands (Redis 7.4+) - HEXPIRE/HPEXPIRE/HEXPIREAT/HPEXPIREAT (set field expiration), HPERSIST (remove field expiration), HTTL/HPTTL (get field TTL), HEXPIRETIME/HPEXPIRETIME (get field expiration timestamp) - fine-grained expiration control for hash fields
Iteration 52: Hash atomic commands (Redis 8.0+) - HGETDEL (atomically get and delete fields), HGETEX (atomically get and set field expiration), HSETEX (atomically set fields with expiration and conditionals FNX/FXX/KEEPTTL) - Phase 1.1 core hash command gaps from PRD
Iteration 53: Sorted set store and intersection cardinality — ZRANGESTORE (store ZRANGE result in destination key, returns member count), ZINTERCARD (count intersection cardinality with LIMIT support for early exit optimization)
Iteration 54: Stream consumer management — XGROUP CREATECONSUMER (explicitly create consumer in group, returns 1 if new/0 if exists), XGROUP DELCONSUMER (delete consumer from group, returns pending message count) - Phase 1.3 stream command gaps from PRD
Roadmap
Project structure and build system
TCP server implementation
RESP2 protocol parser
Basic commands (GET, SET, DEL)
String operations (PING, EXISTS)
Key expiration (EX, PX options)
List operations (LPUSH, RPUSH, LPOP, RPOP, LRANGE, LLEN, +10 more)