Redis Compatibility
Swytch provides a Redis-compatible server that supports the vast majority of Redis commands. It can operate in pure in-memory mode or with persistent tiered storage that survives restarts.
# 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 --join somecluster.example.com
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 |
EXPIRE, EXPIREAT, PEXPIRE, PEXPIREAT | Set expiration |
TTL, PTTL, EXPIRETIME, PEXPIRETIME | Get expiration |
PERSIST | Remove expiration |
RENAME, RENAMENX | Rename keys |
COPY, MOVE | Copy/move between databases |
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 |
| 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 transaction |
EXEC | Execute transaction |
DISCARD | Abort transaction |
WATCH, UNWATCH | Optimistic locking |
| 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, SWAPDB | Database selection |
INFO, DBSIZE, TIME | Server information |
FLUSHDB, FLUSHALL | Clear databases |
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 |
--databases | 16 | Number of databases |
--maxmemory | 64mb | Memory limit (e.g., 256mb, 4gb). Default is suitable for testing |
--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 |
|---|---|---|
--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 | - | DNS name to resolve for cluster peer discovery |
--cluster-port | port + 1000 | QUIC port for cluster traffic |
--cluster-advertise | auto-detect | Address:port this node advertises to peers |
--join requires --cluster-passphrase. See the Deployment guide for clustering
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 |
By default, Swytch runs as a pure in-memory cache. Data is lost on restart but performance is maximised.
swytch redis --maxmemory=4gb
When running in a cluster (--join), data is replicated across nodes via the effects engine. See 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.
Redis modules are not supported.
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 are supported via the gopher-lua interpreter. Most redis.* API calls work, but the following features are
not available:
- 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 only allows a single database across the cluster. Use a separate Swytch instance for multi-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
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
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.