Skip to main content
Swytch Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

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.

Quick Start

# 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

Supported Commands

Swytch implements a comprehensive set of Redis commands across all major data types.

Strings

CommandDescription
GET, SET, SETNX, SETEX, PSETEXBasic get/set operations
MGET, MSET, MSETNXMulti-key operations
GETEX, GETDEL, GETSETGet with side effects
INCR, DECR, INCRBY, DECRBY, INCRBYFLOATAtomic counters
APPEND, STRLENString manipulation
GETRANGE, SETRANGESubstring operations
LCSLongest common subsequence

Keys

CommandDescription
DEL, EXISTS, TYPEKey inspection and deletion
EXPIRE, EXPIREAT, PEXPIRE, PEXPIREATSet expiration
TTL, PTTL, EXPIRETIME, PEXPIRETIMEGet expiration
PERSISTRemove expiration
RENAME, RENAMENXRename keys
COPY, MOVECopy/move between databases
KEYS, SCAN, RANDOMKEYKey enumeration
SORT, SORT_ROSort list/set/zset contents

Bitmaps

CommandDescription
SETBIT, GETBITIndividual bit operations
BITCOUNTCount set bits
BITPOSFind first set/clear bit
BITOPBitwise AND, OR, XOR, NOT
BITFIELD, BITFIELD_ROArbitrary bit field operations

Lists

CommandDescription
LPUSH, RPUSH, LPUSHX, RPUSHXAdd elements
LPOP, RPOPRemove and return elements
BLPOP, BRPOPBlocking pop
LMPOP, BLMPOPPop from multiple lists
LMOVE, BLMOVEAtomically move elements
RPOPLPUSH, BRPOPLPUSHPop and push (deprecated)
LLEN, LRANGE, LINDEXInspection
LSET, LINSERT, LPOSModification
LREM, LTRIMRemoval

Hashes

CommandDescription
HGET, HSET, HSETNX, HMGET, HMSETGet/set fields
HDEL, HEXISTSDelete and check fields
HGETALL, HKEYS, HVALS, HLENEnumerate hash
HINCRBY, HINCRBYFLOATAtomic field increment
HSTRLEN, HRANDFIELDField utilities
HSCANIncremental iteration
HEXPIRE, HPEXPIRE, HTTL, HPTTLPer-field expiration
HGETDEL, HSETEX, HGETEXExtended operations

Sets

CommandDescription
SADD, SREM, SPOPAdd/remove members
SCARD, SISMEMBER, SMISMEMBERMembership tests
SMEMBERS, SRANDMEMBERRetrieve members
SINTER, SINTERSTORE, SINTERCARDIntersection
SUNION, SUNIONSTOREUnion
SDIFF, SDIFFSTOREDifference
SMOVEMove between sets

Sorted Sets

CommandDescription
ZADD, ZREM, ZINCRBYAdd/remove/increment
ZSCORE, ZMSCORE, ZCARDScore lookup
ZRANK, ZREVRANKRank lookup
ZRANGE, ZREVRANGERange by rank
ZRANGEBYSCORE, ZREVRANGEBYSCORERange by score
ZRANGEBYLEX, ZREVRANGEBYLEXRange by lex
ZCOUNT, ZLEXCOUNTCount in range
ZPOPMIN, ZPOPMAX, BZPOPMIN, BZPOPMAXPop min/max
ZMPOP, BZMPOPPop from multiple zsets
ZREMRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYLEXRemove ranges
ZUNION, ZINTER, ZDIFFSet operations
ZUNIONSTORE, ZINTERSTORE, ZDIFFSTOREStore set operations
ZINTERCARDIntersection cardinality
ZRANGESTORE, ZRANDMEMBERUtilities

Streams

CommandDescription
XADD, XLEN, XDEL, XTRIMBasic stream operations
XRANGE, XREVRANGE, XREADRead entries
XGROUPConsumer group management
XREADGROUPRead as consumer group
XACK, XPENDINGAcknowledgment
XCLAIM, XAUTOCLAIMClaim pending entries
XINFO, XSETIDStream information

HyperLogLog

CommandDescription
PFADDAdd elements
PFCOUNTEstimate cardinality
PFMERGEMerge HyperLogLogs

Geospatial

CommandDescription
GEOADDAdd locations
GEODISTDistance between points
GEOHASH, GEOPOSGet hash/coordinates
GEORADIUS, GEORADIUSBYMEMBERSearch by radius (deprecated)
GEOSEARCH, GEOSEARCHSTORESearch locations

Pub/Sub

CommandDescription
SUBSCRIBE, UNSUBSCRIBEChannel subscription
PSUBSCRIBE, PUNSUBSCRIBEPattern subscription
PUBLISHPublish message
PUBSUBIntrospection

Transactions

CommandDescription
MULTIStart transaction
EXECExecute transaction
DISCARDAbort transaction
WATCH, UNWATCHOptimistic locking

Scripting

CommandDescription
EVAL, EVALSHAExecute Lua scripts
EVAL_RO, EVALSHA_RORead-only script execution
SCRIPTScript management
FUNCTION, FCALL, FCALL_ROFunction library support

Server

CommandDescription
PING, ECHOConnection test
AUTH, HELLOAuthentication
SELECT, SWAPDBDatabase selection
INFO, DBSIZE, TIMEServer information
FLUSHDB, FLUSHALLClear databases
CONFIG, CLIENT, MEMORYServer management
COMMANDCommand introspection
ACLAccess control lists
SHUTDOWNStop server

Command-Line Options

Standard Redis Options

OptionDefaultDescription
--port6379TCP port to listen on
--bind127.0.0.1Bind address
--unixsocket-Unix socket path
--unixsocketperm0700Unix socket permissions
--databases16Number of databases
--maxmemory64mbMemory 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
--maxclients0Max connections (0 = unlimited)
--timeout0Client idle timeout in seconds
--threads0Sets 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.

TLS Options

OptionDefaultDescription
--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-version1.2Minimum 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.

Cluster Options

OptionDefaultDescription
--cluster-passphrase-Shared passphrase for cluster mTLS (generate with swytch gen-passphrase)
--join-DNS name to resolve for cluster peer discovery
--cluster-portport + 1000QUIC port for cluster traffic
--cluster-advertiseauto-detectAddress:port this node advertises to peers

--join requires --cluster-passphrase. See the Deployment guide for clustering setup.

Observability Options

OptionDefaultDescription
--metrics-port-Enable Prometheus metrics on this port (e.g., 9090)
--otel-endpoint-OTLP HTTP endpoint for tracing (e.g., localhost:4318)
--otel-insecurefalseUse 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.

Logging Options

OptionDefaultDescription
-vfalseVerbose output (debug-level logging)
--debugfalseLog all commands processed
--log-formattextLog output format: text or json

In-Memory Mode

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.

Unsupported Features

Cluster Mode

Redis Cluster commands are not supported. Swytch is designed for appearing as a single-node Redis instance, even while clustered.

Replication

Replication commands (SYNC, PSYNC, REPLCONF, WAIT) are stubbed but non-functional. There is no master/replica support.

Modules

Redis modules are not supported.

Specific Commands

  • OBJECT - Object introspection is not implemented
  • DEBUG - Most debug subcommands not implemented
  • SLOWLOG - Slow query log not implemented
  • LATENCY - Latency monitoring not implemented
  • CLIENT PAUSE/UNPAUSE - Not implemented
  • CLUSTER * - All Redis Cluster commands (Swytch uses its own clustering model)

Differences from Redis

Eviction Policy

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 Reporting

Memory usage statistics may differ from Redis due to different internal data structures and Go’s memory allocator.

Lua Scripting

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.

Multi-Database

Swytch only allows a single database across the cluster. Use a separate Swytch instance for multi-databases.

Access Control Lists (ACLs)

Swytch supports Redis-compatible ACLs for fine-grained user authentication and authorization.

ACL File Format

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

ACL Rules

RuleDescription
on / offEnable or disable user
>passwordAdd a password (plaintext, hashed with bcrypt internally)
#hashAdd a pre-hashed bcrypt password
<password / !hashRemove a password
nopassAllow connections without a password
~patternAllow read/write access to keys matching the glob pattern
%R~patternRead-only access to matching keys
%W~patternWrite-only access to matching keys
allkeys or ~*Access all keys
resetkeysRemove all key patterns
&patternAllow pub/sub channel access
&*Access all channels
resetchannelsRemove all channel patterns
+commandAllow a command
-commandDeny a command
+@categoryAllow all commands in a category
-@categoryDeny all commands in a category
allcommands or +@allAllow all commands
+command|subcommandAllow a specific subcommand
resetClear all permissions

ACL Commands

CommandDescription
ACL SETUSER username [rule ...]Create or modify a user
ACL GETUSER usernameGet a user’s rules
ACL DELUSER username [...]Delete users
ACL LISTList all users and their rules
ACL USERSList all usernames
ACL CAT [category]List command categories or commands in a category
ACL WHOAMIGet the current connection’s username
ACL GENPASS [bits]Generate a random password
ACL LOADReload ACL file from disk
ACL SAVESave 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

Example Usage

# 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

Monitoring

Prometheus Metrics

Enable Prometheus metrics for monitoring:

swytch redis --metrics-port=9090

Scrape metrics from http://localhost:9090/metrics.

INFO Command

Use the standard Redis INFO command for server statistics:

redis-cli INFO

Version

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

Operations

Signal Handling

Swytch handles POSIX signals for graceful shutdown:

SignalBehavior
SIGTERMGraceful shutdown. Completes in-flight requests, flushes pending writes, exits
SIGINTSame as SIGTERM (Ctrl+C)
SIGHUPNot handled (no config reload)

For container orchestration (Kubernetes, Docker), send SIGTERM to gracefully stop the server. Swytch will:

  1. Stop accepting new connections
  2. Complete in-flight commands
  3. Shut down cluster connections (if clustered)
  4. Exit cleanly

There is no drain period configuration; shutdown completes as fast as pending work allows.