Redis Commands and CLI
Look up supported commands, command-line flags, and compatibility differences. For your first connection, use the Kubernetes quickstart or compatibility overview. For application examples, use the data structure guides.
# Start with defaults (64MB memory, port 6379)
swytch redis
# Production setup with 4GB memory
swytch redis --maxmemory=4gb --bind=0.0.0.0
# Production setup with metrics
swytch redis --maxmemory=4gb --bind=0.0.0.0 --metrics-port=9090
# Join a cluster
swytch redis --bind=0.0.0.0 --cluster-passphrase="YOUR_PASSPHRASE" \
--cluster-port 7379 \
--cluster-advertise 10.0.0.2:7379 \
--join 10.0.0.1:7379
Development builds expose CONFIG SET|GET cluster_safe_mode and CONFIG SET|GET key_safe_mode for
cluster and per-key safety policies, including Redis glob patterns such as sessions::*.
Swytch implements a comprehensive set of Redis commands across all major data types.
| Command | Description |
|---|---|
GET, SET, SETNX, SETEX, PSETEX | Basic get/set operations |
MGET, MSET, MSETNX | Multi-key operations |
GETEX, GETDEL, GETSET | Get with side effects |
INCR, DECR, INCRBY, DECRBY, INCRBYFLOAT | Atomic counters |
APPEND, STRLEN | String manipulation |
GETRANGE, SETRANGE | Substring operations |
LCS | Longest common subsequence |
| Command | Description |
|---|---|
DEL, EXISTS, TYPE | Key inspection and deletion |
UNLINK key [key ...] | Same synchronous deletion as DEL; returns the number of keys removed, ignoring missing keys. No background memory freeing. |
EXPIRE, EXPIREAT, PEXPIRE, PEXPIREAT | Set expiration |
TTL, PTTL, EXPIRETIME, PEXPIRETIME | Get expiration |
PERSIST | Remove expiration |
RENAME, RENAMENX | Rename keys |
COPY, MOVE | Copy keys (MOVE always errors: single database) |
KEYS, SCAN, RANDOMKEY | Key enumeration |
SORT, SORT_RO | Sort list/set/zset contents |
| Command | Description |
|---|---|
SETBIT, GETBIT | Individual bit operations |
BITCOUNT | Count set bits |
BITPOS | Find first set/clear bit |
BITOP | Bitwise AND, OR, XOR, NOT |
BITFIELD, BITFIELD_RO | Arbitrary bit field operations |
| Command | Description |
|---|---|
LPUSH, RPUSH, LPUSHX, RPUSHX | Add elements |
LPOP, RPOP | Remove and return elements |
BLPOP, BRPOP | Blocking pop |
LMPOP, BLMPOP | Pop from multiple lists |
LMOVE, BLMOVE | Atomically move elements |
RPOPLPUSH, BRPOPLPUSH | Pop and push (deprecated) |
LLEN, LRANGE, LINDEX | Inspection |
LSET, LINSERT, LPOS | Modification |
LREM, LTRIM | Removal |
| Command | Description |
|---|---|
HGET, HSET, HSETNX, HMGET, HMSET | Get/set fields |
HDEL, HEXISTS | Delete and check fields |
HGETALL, HKEYS, HVALS, HLEN | Enumerate hash |
HINCRBY, HINCRBYFLOAT | Atomic field increment |
HSTRLEN, HRANDFIELD | Field utilities |
HSCAN | Incremental iteration |
HEXPIRE, HPEXPIRE, HTTL, HPTTL | Per-field expiration |
HGETDEL, HSETEX, HGETEX | Extended operations |
| Command | Description |
|---|---|
SADD, SREM, SPOP | Add/remove members |
SCARD, SISMEMBER, SMISMEMBER | Membership tests |
SMEMBERS, SRANDMEMBER | Retrieve members |
SINTER, SINTERSTORE, SINTERCARD | Intersection |
SUNION, SUNIONSTORE | Union |
SDIFF, SDIFFSTORE | Difference |
SMOVE | Move between sets |
| Command | Description |
|---|---|
ZADD, ZREM, ZINCRBY | Add/remove/increment |
ZSCORE, ZMSCORE, ZCARD | Score lookup |
ZRANK, ZREVRANK | Rank lookup |
ZRANGE, ZREVRANGE | Range by rank |
ZRANGEBYSCORE, ZREVRANGEBYSCORE | Range by score |
ZRANGEBYLEX, ZREVRANGEBYLEX | Range by lex |
ZCOUNT, ZLEXCOUNT | Count in range |
ZPOPMIN, ZPOPMAX, BZPOPMIN, BZPOPMAX | Pop min/max |
ZMPOP, BZMPOP | Pop from multiple zsets |
ZREMRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYLEX | Remove ranges |
ZUNION, ZINTER, ZDIFF | Set operations |
ZUNIONSTORE, ZINTERSTORE, ZDIFFSTORE | Store set operations |
ZINTERCARD | Intersection cardinality |
ZRANGESTORE, ZRANDMEMBER | Utilities |
| Command | Description |
|---|---|
XADD, XLEN, XDEL, XTRIM | Basic stream operations |
XRANGE, XREVRANGE, XREAD | Read entries |
XGROUP | Consumer group management |
XREADGROUP | Read as consumer group |
XACK, XPENDING | Acknowledgment |
XCLAIM, XAUTOCLAIM | Claim pending entries |
XINFO, XSETID | Stream information |
RedisJSON commands are built in. Use them to read and update structured documents by path.
| Command | Description |
|---|---|
JSON.SET, JSON.GET, JSON.MSET, JSON.MGET | Read and write documents or paths |
JSON.MERGE | Merge a JSON value into a document |
JSON.DEL, JSON.FORGET, JSON.CLEAR | Remove or clear values |
JSON.TYPE, JSON.RESP, JSON.DEBUG | Inspect values and their representation |
JSON.NUMINCRBY, JSON.NUMMULTBY, JSON.NUMPOWBY | Update numeric values |
JSON.STRAPPEND, JSON.STRLEN | Append to or measure strings |
JSON.ARRAPPEND, JSON.ARRINSERT, JSON.ARRPOP, JSON.ARRTRIM | Modify arrays |
JSON.ARRLEN, JSON.ARRINDEX | Inspect arrays |
JSON.OBJKEYS, JSON.OBJLEN | Inspect objects |
JSON.TOGGLE | Toggle boolean values |
See JSON documents for examples and path behavior.
| Command | Description |
|---|---|
PFADD | Add elements |
PFCOUNT | Estimate cardinality |
PFMERGE | Merge HyperLogLogs |
| Command | Description |
|---|---|
GEOADD | Add locations |
GEODIST | Distance between points |
GEOHASH, GEOPOS | Get hash/coordinates |
GEORADIUS, GEORADIUSBYMEMBER | Search by radius (deprecated) |
GEOSEARCH, GEOSEARCHSTORE | Search locations |
| Command | Description |
|---|---|
SUBSCRIBE, UNSUBSCRIBE | Channel subscription |
PSUBSCRIBE, PUNSUBSCRIBE | Pattern subscription |
PUBLISH | Publish message |
PUBSUB | Introspection |
| Command | Description |
|---|---|
MULTI | Start a transaction; capture its snapshot with --ssi |
EXEC | Commit and return results; with --ssi, commands have already executed on the snapshot |
DISCARD | Discard queued commands or pending SSI writes |
WATCH, UNWATCH | Optimistic locking |
By default, commands inside MULTI return QUEUED. Start with swytch redis --ssi for immediate results on the
transaction snapshot, including its earlier writes. Make decisions in application code, then commit with EXEC.
EXEC returns the collected results without rerunning commands; a confirmed conflict returns null. Use one connection
and retry the entire transaction after a confirmed abort. See real transactions for client
examples, error handling, and commands that cannot run inside SSI.
Lua scripts and functions are provided on a best-effort basis for Redis compatibility. Lua is not required to write transactional application logic in Swytch; SSI transactions are recommended for new code.
| Command | Description |
|---|---|
EVAL, EVALSHA | Execute Lua scripts |
EVAL_RO, EVALSHA_RO | Read-only script execution |
SCRIPT | Script management |
FUNCTION, FCALL, FCALL_RO | Function library support |
| Command | Description |
|---|---|
PING, ECHO | Connection test |
AUTH, HELLO | Authentication |
SELECT | Accepted for compatibility (SELECT 0 only) |
INFO, DBSIZE, TIME | Server information |
FLUSHDB, FLUSHALL | Clear the database |
CONFIG, CLIENT, MEMORY | Server management |
COMMAND | Command introspection |
ACL | Access control lists |
SHUTDOWN | Stop server |
| Option | Default | Description |
|---|---|---|
--port | 6379 | TCP port to listen on |
--bind | 127.0.0.1 | Bind address |
--unixsocket | - | Unix socket path |
--unixsocketperm | 0700 | Unix socket permissions |
--maxmemory | 64mb | Memory limit (e.g., 256mb, 4gb). Default is suitable for testing |
--compress | false | Store values ZSTD-compressed inside effects: more resident data per byte of memory, decompression on read. Nodes with any setting interoperate |
--requirepass | - | Password for AUTH (deprecated, use --aclfile) |
--aclfile | - | Path to ACL file for user authentication |
--maxclients | 0 | Max connections (0 = unlimited) |
--timeout | 0 | Client idle timeout in seconds |
--threads | 0 | Sets GOMAXPROCS (0 = all CPUs) |
Note: There is no --maxmemory-policy flag. Swytch uses a self-tuning frequency-based eviction algorithm that
automatically adapts to your workload. See Eviction Policy below.
| Option | Default | Description |
|---|---|---|
--ssi | false | Return actual snapshot results inside MULTI instead of QUEUED; commit at EXEC. |
This startup flag applies to connections to the server. Redis transaction helpers that require QUEUED replies need
adaptation. See SSI client usage.
| Option | Default | Description |
|---|---|---|
--data-dir | unset | Mirror resident effects to this directory and restore them before serving clients |
This startup flag is also available on swytch sql. It is not a Redis CONFIG SET parameter. Each process needs a
separate directory. See local durability for setup, sync timing, and the destructive
fallback when recovery cannot fit the memory budget.
| Option | Default | Description |
|---|---|---|
--tls-cert-file | - | Path to TLS certificate file (PEM format) |
--tls-key-file | - | Path to TLS private key file (PEM format) |
--tls-ca-cert-file | - | Path to CA certificate for client verification (mTLS) |
--tls-min-version | 1.2 | Minimum TLS version: 1.0, 1.1, 1.2, 1.3 |
Both --tls-cert-file and --tls-key-file must be specified together. Adding --tls-ca-cert-file enables mutual
TLS, requiring clients to present a certificate signed by the given CA.
| Option | Default | Description |
|---|---|---|
--cluster-passphrase | - | Shared passphrase for cluster mTLS (generate with swytch gen-passphrase) |
--join | - | Bootstrap peer at ip:port, or a comma-separated list of peer endpoints |
--cloud | - | Swytch Cloud connection secret (generate with swytch gen-passphrase --cloud). Derives the cluster identity and discovers peers via Cloud, so it replaces --cluster-passphrase and --join |
--cluster-port | port + 1000 | QUIC port for cluster traffic |
--cluster-advertise | auto-detect | This node’s reachable ip:port; set it explicitly so peers can reach its QUIC listener |
--join requires --cluster-passphrase. --cloud is mutually exclusive with both. See the
Deployment guide for clustering and Swytch Cloud setup.
| Option | Default | Description |
|---|---|---|
--metrics-port | - | Enable Prometheus metrics on this port (e.g., 9090) |
--otel-endpoint | - | OTLP HTTP endpoint for tracing (e.g., localhost:4318) |
--otel-insecure | false | Use HTTP instead of HTTPS for OTLP endpoint |
--pprof | - | Enable pprof profiling on this address (e.g., localhost:6060) |
See the Observability guide for details on all available metrics and tracing.
| Option | Default | Description |
|---|---|---|
-v | false | Verbose output (debug-level logging) |
--debug | false | Log all commands processed |
--log-format | text | Log output format: text or json |
Without --data-dir, Swytch keeps its local state in memory. A standalone process starts empty after a restart.
swytch redis --maxmemory=4gb
A surviving subscriber may retain a key after a clustered node restarts; adding peers does not automatically copy every key. Enable local durability to restore synced resident effects from that node’s disk:
swytch redis --maxmemory=4gb --data-dir=/var/lib/swytch
Eviction removes unreferenced mirror records. Writes return before file syncing completes; the oldest unsynced write sets a 10 ms scheduling deadline. If recovery exceeds its memory budget, Swytch warns and waits 30 seconds before deleting the mirror and starting empty unless stopped. Use Swytch Cloud for a network storage tier, and the deployment guide for cluster setup.
Redis Cluster commands are not supported. Swytch is designed for appearing as a single-node Redis instance, even while clustered.
Replication commands (SYNC, PSYNC, REPLCONF, WAIT) are stubbed but non-functional. There is no master/replica
support.
Swytch includes the RedisJSON JSON.* command family directly in the server; no separate JSON module installation is
required. See JSON commands and the JSON guide. Check other module requirements individually
rather than assuming support from Redis protocol compatibility.
OBJECT- Object introspection is not implementedDEBUG- Most debug subcommands not implementedSLOWLOG- Slow query log not implementedLATENCY- Latency monitoring not implementedCLIENT PAUSE/UNPAUSE- Not implementedCLUSTER *- All Redis Cluster commands (Swytch uses its own clustering model)
Swytch uses a self-tuning frequency-based eviction algorithm instead of Redis’s configurable LRU/LFU policies. This typically results in better hit rates without manual tuning.
Memory usage statistics may differ from Redis due to different internal data structures and Go’s memory allocator.
Lua scripts and functions have best-effort compatibility support through the gopher-lua interpreter. They are optional: Swytch’s SSI transactions let you read, decide, and write in application code without a Lua script. Prefer SSI for new transactional logic, and test any existing scripts you retain against the version you deploy.
The following Lua compatibility limits apply:
- cjson - JSON encoding/decoding (
cjson.encode,cjson.decode) is not implemented - cmsgpack - MessagePack serialization is not implemented
- redis.sha1hex () – SHA1 hashing helper is not implemented
- bit.tohex – Has a known bug with certain edge cases
If you encounter other incompatibilities, please report them at the issue tracker.
Swytch is single-database only. SELECT 0 is accepted for client compatibility; any other index returns an error,
as do SWAPDB and MOVE. Use a separate Swytch instance if you need multiple databases.
Swytch supports Redis-compatible ACLs for fine-grained user authentication and authorization.
Create an ACL file and pass it with --aclfile:
swytch redis --aclfile /etc/swytch/users.acl
The file contains one user definition per line:
# Default user with full access and a password
user default on >mypassword ~* &* +@all
# Read-only user for monitoring
user monitor on >monpass ~* &* +@read -@write -@admin
# Application user with access to specific key prefixes
user myapp on >apppass ~app:* ~session:* &* +@all -@admin
# Disabled user
user old_user off
| Rule | Description |
|---|---|
on / off | Enable or disable user |
>password | Add a password (plaintext, hashed with bcrypt internally) |
#hash | Add a pre-hashed bcrypt password |
<password / !hash | Remove a password |
nopass | Allow connections without a password |
~pattern | Allow read/write access to keys matching the glob pattern |
%R~pattern | Read-only access to matching keys |
%W~pattern | Write-only access to matching keys |
allkeys or ~* | Access all keys |
resetkeys | Remove all key patterns |
&pattern | Allow pub/sub channel access |
&* | Access all channels |
resetchannels | Remove all channel patterns |
+command | Allow a command |
-command | Deny a command |
+@category | Allow all commands in a category |
-@category | Deny all commands in a category |
allcommands or +@all | Allow all commands |
+command|subcommand | Allow a specific subcommand |
reset | Clear all permissions |
| Command | Description |
|---|---|
ACL SETUSER username [rule ...] | Create or modify a user |
ACL GETUSER username | Get a user’s rules |
ACL DELUSER username [...] | Delete users |
ACL LIST | List all users and their rules |
ACL USERS | List all usernames |
ACL CAT [category] | List command categories or commands in a category |
ACL WHOAMI | Get the current connection’s username |
ACL GENPASS [bits] | Generate a random password |
ACL LOAD | Reload ACL file from disk |
ACL SAVE | Save current ACLs to the configured file |
ACL LOG [count|RESET] | View or reset the ACL denial log |
ACL DRYRUN username command [args...] | Test permissions without executing |
# Connect with redis-cli
$ redis-cli -p 6379
# Basic operations
127.0.0.1:6379> SET mykey "Hello World"
OK
127.0.0.1:6379> GET mykey
"Hello World"
# With expiration
127.0.0.1:6379> SETEX session:123 3600 "user-data"
OK
127.0.0.1:6379> TTL session:123
(integer) 3600
# Lists
127.0.0.1:6379> RPUSH mylist a b c
(integer) 3
127.0.0.1:6379> LRANGE mylist 0 -1
1) "a"
2) "b"
3) "c"
# 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"
# Transactions in default mode (without --ssi)
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> INCR counter
QUEUED
127.0.0.1:6379> INCR counter
QUEUED
127.0.0.1:6379> EXEC
1) (integer) 1
2) (integer) 2
For immediate replies and application-side decisions, start with --ssi and follow the
SSI transaction walkthrough.
Enable Prometheus metrics for monitoring:
swytch redis --metrics-port=9090
Scrape metrics from http://localhost:9090/metrics.
Use the standard Redis INFO command for server statistics:
redis-cli INFO
Check the Swytch version:
# CLI version
swytch --version
# Server version (via redis-cli)
redis-cli INFO server | grep redis_version
# Returns: redis_version:8.4.0-swytch
Swytch handles POSIX signals for graceful shutdown:
| Signal | Behavior |
|---|---|
SIGTERM | Graceful shutdown. Completes in-flight requests, flushes pending writes, exits |
SIGINT | Same as SIGTERM (Ctrl+C) |
SIGHUP | Not handled (no config reload) |
For container orchestration (Kubernetes, Docker), send SIGTERM to gracefully stop the server. Swytch will:
- Stop accepting new connections
- Complete in-flight commands
- Shut down cluster connections (if clustered)
- Exit cleanly
There is no drain period configuration; shutdown completes as fast as pending work allows.