Skip to content
wafPublic

About

Command Line redis client focused on performance and value decoding/decompression

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

redirepl

redirepl is a Redis/Valkey interactive command-line tool. It accepts similar flags as redis-cli and produces the same output. In addition, it supports:

  • An interactive prompt with completion and inline documentation
  • Syntax highlighting
  • Decoding/pretty-printing of compressed data and JSON values
  • An architecture that streams large values instead of holding them in memory.

redirepl supports Redis 6.0 or later, or Valkey. This tool has been built with assistance of Claude Code.

Typing at the redirepl prompt: a syntax pane for SCAN, MATCH completing as a keyword argument, and a command list beside its documentation.

Install

Download the archive for your platform from the latest release, extract it, and put redirepl somewhere on your PATH. It is a single native binary with no runtime to install.

Platform Asset
Windows (x64) redirepl-<version>-win-x64.zip
Linux (x64) redirepl-<version>-linux-x64.tar.gz
Linux (arm64) redirepl-<version>-linux-arm64.tar.gz
macOS (Apple Silicon) redirepl-<version>-osx-arm64.tar.gz

On macOS, Gatekeeper quarantines a downloaded binary that is not notarised, so clear the attribute before the first run: xattr -d com.apple.quarantine redirepl.

Usage

redirepl                                    # interactive prompt on 127.0.0.1:6379
redirepl -h cache.internal -p 6380 -n 2     # ...against another server and database
redirepl GET session:123                    # run one command and exit
redirepl --scan --pattern 'user:*'          # list matching keys (SCAN, never KEYS)
redirepl --bigkeys                          # find the largest key of each type

Command-line flags follow redis-cli as closely as possible. Connection, authentication, output format, TLS, --scan, --stat, --latency*, --bigkeys, --memkeys and -c cluster redirects all take the same flags. Run redirepl --help for the list.

redirepl departs from redis-cli in that there is no RESP2 mode, -o <file> is a redirepl addition that outputs to a file, and redirepl renders three frame types that redis-cli does not: big numbers, blob errors and attributes. redirepl does not support --pipe, --rdb, --replica, the Lua debugger and cluster management (connecting to a cluster is supported).

Completion and inline documentation

Run redirepl with no command to open the interactive prompt.

  • Completion of command names, container subcommands (CLIENT → LIST, GETNAME, …) and keyword arguments (SET k v → NX, EX, KEEPTTL, …). Each entry shows a documentation pane with the syntax, summary, version and complexity.
  • Syntax hints. The space after a command opens a pane that shows the full syntax of that command. The argument under the caret is highlighted and described. The pane stays open for the rest of the line.
  • Highlighting. Known commands are green and unknown commands are red. Quoted strings are yellow, numbers are cyan and keywords are magenta, so a typo is visible before you press Enter.
  • F1 opens the documentation for the current command on redis.io, or on valkey.io if the server is Valkey.

The connected server supplies this data through COMMAND DOCS. Module commands and Valkey-specific commands therefore complete correctly, and a new redirepl release is not necessary. An embedded Redis 8.x table is used instead if the server is too old to answer.

The prompt also has multi-line editing and persistent history. An unbalanced quote makes Enter insert a newline instead of submitting the line. Ctrl+C abandons a running command. SUBSCRIBE and MONITOR close the prompt and print messages as they arrive, and Ctrl+C returns to the prompt.

Decoding values

A compressed or JSON value is stored as bytes, and redis-cli prints those bytes. redirepl can decode the value first.

redirepl --decode auto GET session:123           # sniff gzip/zstd/lz4/zlib, then pretty-print JSON
redirepl --decode zstd,json GET big:key          # explicit chain
redirepl --decode gzip -o value.bin GET big:key  # decode straight to a file
redirepl --encode gzip -x SET key < file.json    # compress before storing
redirepl --encode json -x SET key < file.json    # validate and minify before storing

At the prompt, you can append the same chain to any command, and you can redirect the result to a file:

127.0.0.1:6379> GET session:123 | gzip,json      # decode this reply
127.0.0.1:6379> GET big:key | zstd > value.json  # decode and write to a file
127.0.0.1:6379> :decode auto                     # make it the session default

The byte transforms are gzip zlib deflate br zstd lz4 base64 hex. The terminal formatters are json utf8 hex raw. hex is both, so its position decides which one it is: last means "show the value as hex", and earlier means "the value is hex text, decode it".

redirepl decodes bulk-string values anywhere in a reply, but it never decodes keys. For example, HGETALL | zstd,json decodes every field value. A chain of byte transforms is a pure stream, so redirepl can decode a value that is too large to hold in memory.

If a --decode stage fails, redirepl writes a diagnostic to stderr, shows the output of the last stage that worked, and leaves the exit code unchanged, because a decode failure affects the display only. If an --encode stage fails, redirepl stops with an error, because it must not store bytes that you did not supply.

Performance

dotnet publish produces one native binary of approximately 9 MB (PublishAot), and there is no runtime to install. The binary starts in approximately 14 ms. On the same machine, redis-cli 8.10.0 starts in 20 ms.

redirepl never holds a value larger than 1 MiB in memory. The parser gives the renderer a bounded PipeReader that is a slice of the connection input pipe, so memory use stays proportional to one pipe segment rather than to the value:

Operation Managed allocations
GET of a 48 MiB value, end to end over a socket 314 KB
Parse and render 48 MiB, raw / JSON / human 161 KB
GET of a 256 KiB value 904 B
PING 656 B

One keystroke at the prompt runs four callbacks: highlighting, the syntax span, completions and overloads. Together they take approximately 3 µs and allocate approximately 9 KB on a typical line.

These numbers come from Redirepl.Benchmarks. Its reports are committed, so you can read the last measurement without a new run. To measure again, run dotnet run -c Release --project Redirepl.Benchmarks.

Build

dotnet build Redirepl.slnx
dotnet test Redirepl.slnx                          # needs Docker
dotnet publish Redirepl/Redirepl.csproj -c Release # single native binary

Tests run against a real server. Testcontainers starts a redis:8.10.0 container for the test run, and no server of yours is used. If redis-cli is also on PATH, the parity suite sends every reply shape through both binaries and compares the exact stdout bytes and exit codes.

About

Command Line redis client focused on performance and value decoding/decompression

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages