Reference
Data type commands
Klyro implements 145 commands: 130 Redis-shaped commands plus the 15-command MEM.* family. Matching RESP reply shapes let standard client libraries decode the results.
Choose a language once and every tabbed example in the documentation follows that choice. The preference is stored only in this browser.
Generic (any type)
| Command | Reply |
|---|---|
| PING [message] | PONG, or the message |
| ECHO message | The message |
| HELLO [protover] | Server info; HELLO 3 switches to RESP3 |
| DEL key [key ...] / UNLINK key [key ...] | Number of keys removed |
| EXISTS key [key ...] | How many exist; a repeated key counts each time |
| EXPIRE key seconds / PEXPIRE key ms | 1 if the TTL was set, 0 if the key is missing |
| EXPIREAT key unix-seconds / PEXPIREAT key unix-ms | 1 or 0 |
| PERSIST key | 1 if a TTL was removed, else 0 |
| TTL key / PTTL key | Time left, -1 no expiry, -2 missing |
| TYPE key | string, list, hash, set, zset, memory, or none |
| RENAME key newkey / RENAMENX key newkey | OK, or 1/0 for the NX form |
| COPY source destination [REPLACE] | 1 if copied, else 0 |
| RANDOMKEY | A key, or nil if the keyspace is empty |
| KEYS pattern | Array of matching keys |
| SCAN cursor [MATCH pattern] [COUNT count] | [next-cursor, [keys...]] |
| DBSIZE | Number of live keys |
| FLUSHDB / FLUSHALL | OK; one keyspace, so both do the same thing |
| INFO [section] | One text blob of # Section headers over key:value lines |
| CONFIG GET pattern [pattern ...] | Map of parameter to value |
| CONFIG SET parameter value | OK, or an error explaining the refusal |
| CONFIG RESETSTAT | OK; clears INFO's activity counters |
| SAVE | OK; writes the dump file immediately |
| QUIT / SHUTDOWN | OK, then closes the connection or stops the server |
COPY is a deep copy: mutating the destination afterwards leaves the source untouched. RENAME and COPY both carry the TTL across.
Strings
| Command | Reply |
|---|---|
| SET key value [NX|XX] [GET] [EX s|PX ms|EXAT ts|PXAT ts|KEEPTTL] | OK, or nil when NX/XX is not satisfied |
| SETNX key value | 1 if written, else 0 |
| SETEX key seconds value / PSETEX key ms value | OK |
| GET key | The value, or nil |
| GETSET key value | The previous value, or nil; clears any TTL |
| GETDEL key | The value, or nil; removes the key |
| GETEX key [EX s|PX ms|PERSIST] | The value, or nil; adjusts the TTL |
| MGET key [key ...] | Array of values, nil per missing key |
| MSET key value [key value ...] | OK |
| MSETNX key value [key value ...] | 1 if all were written, 0 if any key existed |
| INCR / DECR / INCRBY / DECRBY key [n] | The new value |
| INCRBYFLOAT key n | The new value, as text |
| APPEND key value | The new length |
| STRLEN key | The length, 0 if missing |
| GETRANGE key start end / SUBSTR key start end | The substring; inclusive, negatives count from the end |
| SETRANGE key offset value | The new length; pads any gap with NUL bytes |
SET key value NX EX 30 takes the key only if nobody holds it, and the lease expires on its own. INCR, DECR, INCRBY, APPEND, and SETRANGE keep an existing TTL; SET without KEEPTTL, GETSET, and MSET clear it.
Lists
| Command | Reply |
|---|---|
| LPUSH / RPUSH key value [value ...] | The new length |
| LPUSHX / RPUSHX key value [value ...] | The new length, or 0 if the key does not exist |
| LPOP / RPOP key [count] | One value or nil; with a count, an array |
| LLEN key | The length |
| LRANGE key start stop | Array of values |
| LINDEX key index | The value, or nil |
| LSET key index value | OK, or an error if the key or index is out of range |
| LINSERT key BEFORE|AFTER pivot value | The new length, -1 if the pivot is absent, 0 if the key is |
| LREM key count value | How many were removed |
| LTRIM key start stop | OK; an empty range deletes the key |
| RPOPLPUSH source destination | The moved value, or nil |
| LMOVE source destination LEFT|RIGHT LEFT|RIGHT | The moved value, or nil |
Hashes
| Command | Reply |
|---|---|
| HSET key field value [field value ...] | Number of fields added |
| HSETNX key field value | 1 if written, 0 if the field exists |
| HMSET key field value [field value ...] | OK |
| HGET key field | The value, or nil |
| HMGET key field [field ...] | Array of values, nil per missing field |
| HDEL key field [field ...] | Number of fields removed |
| HLEN key / HSTRLEN key field | The field count / the value's length |
| HEXISTS key field | 1 or 0 |
| HKEYS key / HVALS key | Array of fields, or of values |
| HGETALL key | Map of field to value |
| HINCRBY key field n / HINCRBYFLOAT key field n | The new value |
Sets
| Command | Reply |
|---|---|
| SADD key member [member ...] | Number of members newly added |
| SREM key member [member ...] | Number removed |
| SISMEMBER key member | 1 or 0 |
| SMISMEMBER key member [member ...] | Array of 1/0, one per member |
| SCARD key / SMEMBERS key | The member count / the members |
| SPOP key [count] | Removes and returns one member or nil; with a count, a set |
| SRANDMEMBER key [count] | The same without removing; a negative count may repeat members |
| SMOVE source destination member | 1 if moved, else 0 |
| SINTER / SUNION / SDIFF key [key ...] | Set of members |
| SINTERSTORE / SUNIONSTORE / SDIFFSTORE dest key [key ...] | Size of the stored result |
A missing key counts as an empty set. SDIFF subtracts every later set from the first, so it is not symmetric. A STORE variant whose result is empty deletes the destination.
Sorted sets
| Command | Reply |
|---|---|
| ZADD key score member [score member ...] | Number of members newly added |
| ZSCORE key member / ZMSCORE key member [member ...] | The score, or nil |
| ZINCRBY key increment member | The new score; a missing member starts at 0 |
| ZREM key member [member ...] | Number removed |
| ZCARD key | The member count |
| ZRANK / ZREVRANK key member | The 0-based rank, or nil |
| ZRANGE / ZREVRANGE key start stop [WITHSCORES] | Members by score |
| ZRANGEBYSCORE / ZREVRANGEBYSCORE key min max [WITHSCORES] | Members inside the score window |
| ZCOUNT key min max | How many fall inside the window |
| ZREMRANGEBYRANK / ZREMRANGEBYSCORE key start stop | Number removed |
| ZPOPMIN / ZPOPMAX key [count] | The popped members with their scores |
Score bounds accept a plain number, -inf/+inf, or a ( prefix for an exclusive bound, as in ZCOUNT board (75 +inf.
Rules that apply everywhere
- A command against a key holding a different type replies
WRONGTYPE, for instanceLPUSHon a key created bySET. - Removing the last element of a collection deletes the key, same as Redis.
- Keys, values, fields, and members are arbitrary bytes: they may contain spaces, newlines, and NUL bytes. So are a memory record’s text and metadata.
- Calling an unimplemented Redis command returns
ERR unknown command. See limitations for what is missing.
