redito — Redis Toolkit CLI
redito is a command-line utility for working with Redis in a structured and
extensible way. It’s designed to support multiple Redis operations through modular
subcommands — starting with some tools for working with Redis Streams.
Why
I frequently work with Redis streams, and Redis in general, and often wish I had some tools that could make my life easier here and there. Couple with a desired to code in Rust, and to get some experience maintaining a solid CLI tool, I decided to lay the foundation for an extensible tool that should be useful to me, and could be useful for others too.
Features
- Supports configuration through:
- Command-line arguments
- Environment variables (prefixed with
REDITO_) - Configuration files (
/etc/redito.toml,./.redito.toml,redito.toml, orlocal_config.toml)
- TLS and Sentinel connection support.
- Stream utilities:
stream-tail— follow a stream liketail -fstream-copy— copy entries between Redis instances
- Built with Rust, so blazingly fast and safe! (sorry, couldn't resist...)
Installation
You can build from source:
Or:
Configuration
redito loads configuration in this order (later entries override earlier ones):
/etc/redito.toml./.redito.toml./redito.tomllocal_config.toml- Environment variables prefixed with
REDITO_ - Command-line flags
I intend to use this tool both as an everyday cli tool, and as an automation helper to be configured in cronjobs and such, which is why I'm putting some effort into it being configurable through config files, environment variables, and command-line arguments all at once.
Example TOML config
[]
= "localhost"
= 6379
= 0
= false
You can override any of these via CLI or environment variables. For example:
REDITO_REDIS__HOST=redis.example.com
Commands
stream-tail
Tails a Redis Stream, continuously reading new entries (similar to tail -f).
Options:
| Option | Description | Default |
|---|---|---|
--stream |
Stream name to read from | (required) |
--plaintext |
Print values as plain text | false |
--raw-key |
Specific field to print instead of full entry | None |
--group |
Consumer group name | None |
--consumer |
Consumer name within group | None |
--block-ms |
Milliseconds to block waiting for new messages | 5000 |
--count |
Number of entries to fetch per request | 1000 |
--start-id |
Stream ID to start reading from | $ |
--retry-when-empty |
Retry when no messages are found | false |
stream-copy
Copies entries from a source Redis stream to a target Redis instance.
Options:
| Option | Description | Default |
|---|---|---|
--stream |
Source stream name | (required) |
--target-host |
Target Redis hostname | (required) |
--target-port |
Target Redis port | 6379 |
--target-username |
Target Redis username | None |
--target-password |
Target Redis password | None |
--target-db |
Target Redis DB index | 0 |
--target-tls |
Use TLS for target connection | false |
--target-sentinel |
Use Redis Sentinel for target | false |
--target-sentinel-master |
Sentinel master name | None |
--group |
Source group name | None |
--consumer |
Source consumer name | None |
--block-ms |
Block duration while polling | 5000 |
--count |
Number of entries per fetch | 1000 |
--start-id |
Start ID in stream | $ |
--retry-when-empty |
Retry on empty reads | false |
Environment Variables
redito recognizes any setting as an environment variable, using the prefix REDITO_.
Nested fields (like Redis connection options) use double underscores __.
Example:
License
Dual-licensed under Apache 2.0 or MIT.