Docs
Redis Protocol
Redis Protocol (RESP2)
Redis-compatible TCP server on port 6379 — 100+ commands across 5 data types, transactions, pub/sub, and persistence
Connection
# Connect with redis-cli (default port 6379)
redis-cli
# Or any Redis client library (ioredis, go-redis, jedis, etc.)
redis = Redis.new(host: "localhost", port: 6379)
Protocol Format
SoliKV speaks RESP2 (REdis Serialization Protocol), the same wire format used by Redis. Both array format and inline commands are supported.
Array format: *3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\nbar\r\n Inline format: SET foo bar\r\n Responses: Simple string: +OK\r\n Error: -ERR message\r\n Integer: :42\r\n Bulk string: $3\r\nbar\r\n Null: $-1\r\n Array: *2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n
100+
commands
5
data types
16
databases
MULTI
transactions
PUB/SUB
messaging
S Strings (16 commands)
| Command | Syntax | Description |
|---|---|---|
| SET | SET key value [NX|XX] [GET] [EX s|PX ms] | Set key with optional flags and TTL |
| GET | GET key | Get value by key |
| SETNX | SETNX key value | Set only if key does not exist |
| SETEX | SETEX key seconds value | Set with expiry in seconds |
| PSETEX | PSETEX key ms value | Set with expiry in milliseconds |
| GETSET | GETSET key value | Set and return old value |
| MSET | MSET key val [key val ...] | Set multiple keys atomically |
| MSETNX | MSETNX key val [key val ...] | Set multiple keys only if none exist |
| MGET | MGET key [key ...] | Get multiple keys |
| APPEND | APPEND key value | Append to string, returns new length |
| STRLEN | STRLEN key | Returns string length |
| INCR | INCR key | Increment by 1, returns new value |
| DECR | DECR key | Decrement by 1 |
| INCRBY | INCRBY key amount | Increment by integer amount |
| DECRBY | DECRBY key amount | Decrement by integer amount |
| INCRBYFLOAT | INCRBYFLOAT key amount | Increment by float amount |
L Lists (13 commands)
Backed by a VecDeque — O(1) LPUSH/RPUSH/LPOP/RPOP at both ends.
| Command | Syntax | Description |
|---|---|---|
| LPUSH | LPUSH key val [val ...] | Push to head, returns length |
| RPUSH | RPUSH key val [val ...] | Push to tail, returns length |
| LPOP | LPOP key | Pop from head |
| RPOP | RPOP key | Pop from tail |
| LLEN | LLEN key | Returns list length |
| LRANGE | LRANGE key start stop | Get range of elements |
| LINDEX | LINDEX key index | Get element by index |
| LSET | LSET key index value | Set element at index |
| LREM | LREM key count value | Remove elements by value |
| LTRIM | LTRIM key start stop | Trim list to range |
| RPOPLPUSH | RPOPLPUSH src dst | Pop tail of src, push to head of dst |
| LINSERT | LINSERT key BEFORE|AFTER pivot val | Insert before or after pivot |
| LPOS | LPOS key value | Find index of value |
H Hashes (11 commands)
| Command | Syntax | Description |
|---|---|---|
| HSET | HSET key field val [field val ...] | Set field(s), returns count of new fields |
| HGET | HGET key field | Get field value |
| HDEL | HDEL key field [field ...] | Delete field(s) |
| HEXISTS | HEXISTS key field | Check if field exists |
| HGETALL | HGETALL key | Get all fields and values |
| HKEYS | HKEYS key | Get all field names |
| HVALS | HVALS key | Get all values |
| HLEN | HLEN key | Returns number of fields |
| HMSET | HMSET key field val [field val ...] | Set multiple fields |
| HMGET | HMGET key field [field ...] | Get multiple fields |
| HINCRBY | HINCRBY key field amount | Increment field by integer |
S Sets (10 commands)
| Command | Syntax | Description |
|---|---|---|
| SADD | SADD key member [member ...] | Add member(s), returns count added |
| SREM | SREM key member [member ...] | Remove member(s) |
| SMEMBERS | SMEMBERS key | Get all members |
| SISMEMBER | SISMEMBER key member | Check membership |
| SCARD | SCARD key | Returns set size |
| SPOP | SPOP key [count] | Remove and return random member(s) |
| SRANDMEMBER | SRANDMEMBER key [count] | Get random member(s) without removing |
| SUNION | SUNION key [key ...] | Union of sets |
| SINTER | SINTER key [key ...] | Intersection of sets |
| SDIFF | SDIFF key [key ...] | Difference of sets |
Z Sorted Sets (12 commands)
| Command | Syntax | Description |
|---|---|---|
| ZADD | ZADD key [NX|XX] [GT|LT] score member [...] | Add members with scores |
| ZREM | ZREM key member [member ...] | Remove member(s) |
| ZSCORE | ZSCORE key member | Get member score |
| ZRANK | ZRANK key member | Get rank (0-based, low to high) |
| ZREVRANK | ZREVRANK key member | Get rank (0-based, high to low) |
| ZRANGE | ZRANGE key start stop [WITHSCORES] | Get range by rank |
| ZREVRANGE | ZREVRANGE key start stop [WITHSCORES] | Get range by rank (reversed) |
| ZRANGEBYSCORE | ZRANGEBYSCORE key min max [LIMIT off cnt] | Get range by score |
| ZCARD | ZCARD key | Returns sorted set size |
| ZCOUNT | ZCOUNT key min max | Count members in score range |
| ZINCRBY | ZINCRBY key increment member | Increment member score |
| ZREMRANGEBYSCORE | ZREMRANGEBYSCORE key min max | Remove members by score range |
K Keys (11 commands)
| Command | Syntax | Description |
|---|---|---|
| DEL | DEL key [key ...] | Delete key(s), returns count deleted |
| EXISTS | EXISTS key [key ...] | Check existence, returns count |
| TYPE | TYPE key | Returns key type (string, list, hash, set, zset) |
| RENAME | RENAME key newkey | Rename key |
| RENAMENX | RENAMENX key newkey | Rename only if newkey does not exist |
| EXPIRE | EXPIRE key seconds | Set TTL in seconds |
| PEXPIRE | PEXPIRE key ms | Set TTL in milliseconds |
| TTL | TTL key | Remaining TTL in seconds |
| PTTL | PTTL key | Remaining TTL in milliseconds |
| PERSIST | PERSIST key | Remove TTL |
| KEYS | KEYS pattern | Find keys matching pattern (*, prefix*, *suffix) |
T Transactions (3 commands)
Queued commands execute atomically under a single write lock.
| Command | Syntax | Description |
|---|---|---|
| MULTI | MULTI | Start transaction |
| EXEC | EXEC | Execute queued commands |
| DISCARD | DISCARD | Discard queued commands |
P Pub/Sub (5 commands)
Uses DashMap + tokio::broadcast channels — pub/sub does not contend with data operations.
| Command | Syntax | Description |
|---|---|---|
| SUBSCRIBE | SUBSCRIBE channel [channel ...] | Subscribe to channel(s) |
| UNSUBSCRIBE | UNSUBSCRIBE [channel ...] | Unsubscribe from channel(s) |
| PSUBSCRIBE | PSUBSCRIBE pattern [pattern ...] | Subscribe to pattern(s) |
| PUNSUBSCRIBE | PUNSUBSCRIBE [pattern ...] | Unsubscribe from pattern(s) |
| PUBLISH | PUBLISH channel message | Publish message, returns receiver count |
* Server (11 commands)
| Command | Syntax | Description |
|---|---|---|
| PING | PING [msg] | Returns PONG or echoes argument |
| ECHO | ECHO message | Echoes message back |
| QUIT | QUIT | Close connection |
| SELECT | SELECT db | Select database (0-15) |
| DBSIZE | DBSIZE | Returns number of keys |
| FLUSHDB | FLUSHDB | Delete all keys in current db |
| FLUSHALL | FLUSHALL | Delete all keys in all databases |
| INFO | INFO [section] | Server information |
| COMMAND | COMMAND [DOCS|COUNT] | Command metadata |
| CONFIG | CONFIG GET pattern | Get configuration |
| TIME | TIME | Server time [seconds, microseconds] |
Examples
redis-cli -p 6379
# Strings
127.0.0.1:6379> SET user:1 Alice EX 3600
OK
127.0.0.1:6379> INCR page:views
(integer) 1
# Lists
127.0.0.1:6379> RPUSH queue job1 job2 job3
(integer) 3
127.0.0.1:6379> LPOP queue
"job1"
# Hashes
127.0.0.1:6379> HSET user:1 name Alice age 30
(integer) 2
127.0.0.1:6379> HGETALL user:1
1) "name"
2) "Alice"
3) "age"
4) "30"
# Sorted sets (leaderboard)
127.0.0.1:6379> ZADD leaderboard 100 alice 200 bob 150 charlie
(integer) 3
127.0.0.1:6379> ZRANGE leaderboard 0 -1 WITHSCORES
1) "alice"
2) "100"
3) "charlie"
4) "150"
5) "bob"
6) "200"
# Transactions
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> SET x 1
QUEUED
127.0.0.1:6379> SET y 2
QUEUED
127.0.0.1:6379> EXEC
1) OK
2) OK
Pipeline Support
Full pipeline support with batch locking and write coalescing. Clients can send multiple commands without waiting for individual responses, achieving 1.6M+ SET/sec and 1.5M+ GET/sec with P=16.
Client Compatibility
redis-cli
ioredis (Node.js)
go-redis (Go)
redis-py (Python)
Jedis (Java)
redis-benchmark