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

Quickstart: Local

Install Swytch, start a local cache, and read and write data with a Redis client. You need a free port 6379 and either a native installation or Docker.

1. Install Swytch

Choose one installation method.

Homebrew: macOS or Linux

brew tap swytchdb/tap
brew install swytch

Nix: Linux or Apple Silicon macOS

The Swytch flake supports x86-64 Linux, ARM64 Linux, and Apple Silicon macOS. You need Nix with nix-command and flakes enabled. If needed, add this line to ~/.config/nix/nix.conf (create the directory and file if they do not exist):

experimental-features = nix-command flakes

Install the swytch CLI into your Nix profile:

nix profile install github:swytchdb/swytch

Then use the native start command in step 2. To try Swytch without installing it into your profile, skip this install and use the nix run command in step 2 instead. The flake builds from the repository’s default branch; use github:swytchdb/swytch/<commit> to pin a commit that contains the flake.

curl: macOS or Linux

curl -fsSL https://getswytch.com/scripts/install.sh | sh

On platforms supported by the flake, the installer uses your Nix profile when nix is available. It enables nix-command and flakes for that command, so you do not need to edit your Nix configuration first. This installs from the repository’s default branch. Set SWYTCH_VERSION to select a release tag that contains flake.nix.

To install a release binary into a specific directory instead, set SWYTCH_INSTALL on the shell running the installer:

curl -fsSL https://getswytch.com/scripts/install.sh | SWYTCH_INSTALL="$HOME/.local/bin" sh

For a release binary, the installer prints the installation directory. It normally uses ~/.local/bin. If that directory is not on your PATH, add it for this terminal:

export PATH="$HOME/.local/bin:$PATH"

Add the same line to your shell configuration to keep it in future terminals.

PowerShell: Windows

iwr -useb https://getswytch.com/scripts/install.ps1 | iex

By default, the installer places swytch.exe in %LOCALAPPDATA%\Programs\swytch. Add it to the current terminal’s PATH:

$env:Path = "$env:LOCALAPPDATA\Programs\swytch;$env:Path"

For future terminals, add that directory to your user PATH in Windows environment settings.

Docker

docker pull ghcr.io/swytchdb/swytch:latest

The latest image is convenient for this walkthrough. Pin a release for deployment. You can also download binaries, checksums, and signatures from Swytch releases.

2. Start the cache

For a native installation, run:

swytch redis --bind 127.0.0.1 --maxmemory 256mb

Leave this terminal running. Swytch accepts Redis connections at 127.0.0.1:6379.

For Nix without a profile installation, run this instead:

nix run github:swytchdb/swytch -- --bind 127.0.0.1 --maxmemory 256mb

The flake’s default app starts swytch redis for you. Pass server flags after --; do not add the redis subcommand. The app defaults to --maxmemory 85%, which this example overrides with 256mb to match the rest of the walkthrough.

For Docker, run this instead:

docker run --rm --name swytch-quickstart -p 127.0.0.1:6379:6379 ghcr.io/swytchdb/swytch:latest redis --bind 0.0.0.0 --maxmemory 256mb

The server listens on the container interface; the published port is available only on your host’s loopback address.

3. Connect a client

Open another terminal. If you already have redis-cli, connect with:

redis-cli -h 127.0.0.1 -p 6379

To install the client on macOS with Homebrew:

brew install redis

On Debian or Ubuntu:

sudo apt-get update
sudo apt-get install redis-tools

You only need the client; Swytch is already serving the Redis endpoint.

With Nix, run the client without installing it into your profile:

nix shell nixpkgs#redis -c redis-cli -h 127.0.0.1 -p 6379

If you chose the Docker server, you can use a client container on any supported host, including Windows:

docker run --rm -it --network container:swytch-quickstart redis:7.4-alpine redis-cli -h 127.0.0.1 -p 6379

This client shares the Swytch container’s network. It does not start another server. For a native Windows installation, use an existing Redis-compatible client at 127.0.0.1:6379, or use the Docker server and client commands above to follow the interactive examples.

4. Use it

At the redis-cli prompt, check the connection and store a value:

PING
SET greeting "hello from Swytch"
GET greeting

Expect PONG, then OK, then "hello from Swytch".

Give a cached value an expiration:

SET session:demo active EX 60
TTL session:demo

TTL reports the remaining lifetime in seconds. After the minute expires, GET session:demo returns nil.

Try a counter and a list:

INCR visits
INCR visits
RPUSH jobs resize:42 resize:43
LPOP jobs

On a fresh instance, the counter replies are 1 and 2. The list push returns 2, and the pop returns "resize:42". Your application’s Redis client can use the same endpoint and commands. See Redis data structures for more examples.

5. Stop the cache

Enter QUIT to leave the client, then press Ctrl+C in the server terminal. The Docker server container is removed automatically because it was started with --rm.

The commands above run without a data directory. Stopping this standalone instance discards its memory-only data; the next start is empty.

Keep resident state across restarts

On a build with local durability support, add --data-dir when starting the native server:

swytch redis --bind 127.0.0.1 --maxmemory 256mb --data-dir ./swytch-data

Writes made by this instance are mirrored locally. Reuse the same directory on later starts. Syncing is asynchronous, and eviction also removes unreferenced records from the mirror.

If recovery cannot fit its memory budget, Swytch warns, waits 30 seconds, then deletes the mirror and starts empty unless you stop it. Read local durability for the restart walkthrough, Docker volume setup, and recovery procedure. Durability and tiering covers retention beyond the local working set or disk.

Where to go next

For questions, discussions, and interesting topics, join us on Discord.