Interactive Redis
IRedis is a terminal client for redis with auto-completion and syntax highlighting. IRedis lets you type Redis commands smoothly, and displays results in a user-friendly format.
IRedis is an alternative for redis-cli. In most cases, IRedis behaves exactly the same as redis-cli. Besides, it is safer to use IRedis on production servers than redis-cli: IRedis will prevent accidentally running dangerous commands, like KEYS * (see Redis docs / Latency generated by slow commands).
Features
- Advanced code completion. If you run command
KEYS
then runDEL
, IRedis
will auto-complete your command based onKEYS
result. - Command validation. IRedis will validate command while you are typing, and
highlight errors. E.g. tryCLUSTER MEET IP PORT
, IRedis will validate IP and
PORT for you. - Command highlighting, fully based on redis grammar. Any valid command in
IRedis shell is a valid redis command. - Human-friendly result display.
- pipeline feature, you can use your favorite shell tools to parse redis'
response, likeget json | jq .
. - Support pager for long output.
- Support connection via URL,
iredis --url redis://example.com:6379/1
. - Store server configuration:
iredis -d prod-redis
(see dsn for
more). peek
command to check the key's type then automatically call
get
/lrange
/sscan
, etc, depending on types. You don't need to call the
type
command then type another command to get the value.peek
will also
display the key's length and memory usage.- Ctrl + C to cancel the current typed command, this won't
exit IRedis, exactly like bash behaviour. Use Ctrl + D
to send a EOF to exit IRedis. - Ctrl + R to open reverse-i-search to search through
your command history. - Auto suggestions. (Like fish shell.)
- Support
--encode=utf-8
, to decode Redis' bytes responses. - Command hint on bottom, include command syntax, supported redis version, and
time complexity. - Official docs with built-in
HELP
command, tryHELP SET
! - Written in pure Python, but IRedis was packaged into a single binary with
PyOxidizer, you can use cURL to
download and run, it just works, even you don't have a Python interpreter. - Hide password for
AUTH
command. - Says "Goodbye!" to you when you exit!
- For full features, please see: iredis.io
Install
Install via pip:
pip install iredis
pipx is recommended:
pipx install iredis
Or you can download the executable binary with cURL(or wget), untar, then run.
It is especially useful when you don't have a python interpreter(E.g. the
official Redis docker image which doesn't
have Python installed.):
wget https://github.com/laixintao/iredis/releases/latest/download/iredis.tar.gz \
&& tar -xzf iredis.tar.gz \
&& ./iredis
(Check the release page if you
want to download an old version of IRedis.)
Usage
Once you install IRedis, you will know how to use it. Just remember, IRedis
supports similar options like redis-cli, like -h
for redis-server's host and
-p
for port.
$ iredis --help
Using DSN
IRedis support storing server configuration in config file. Here is a DSN
config:
[alias_dsn]
dev=redis://localhost:6379/4
staging=redis://username:[email protected]:6379/1
Put this in your iredisrc
then connect via iredis -d staging
or
iredis -d dev
.
Configuration
IRedis supports config files. Command-line options will always take precedence
over config. Configuration resolution from highest to lowest precedence is:
- Options from command line
$PWD/.iredisrc
~/.iredisrc
(this path can be changed withiredis --iredisrc $YOUR_PATH
)/etc/iredisrc
- default config in IRedis package.
You can copy the self-explained default config here:
https://raw.githubusercontent.com/laixintao/iredis/master/iredis/data/iredisrc
And then make your own changes.
(If you are using an old versions of IRedis, please use the config file below,
and change the version in URL):
https://raw.githubusercontent.com/laixintao/iredis/v1.0.4/iredis/data/iredisrc
Keys
IRedis support unix/readline-style REPL keyboard shortcuts, which means keys
like Ctrl + F to forward work.
Also:
- Ctrl + D (i.e. EOF) to exit; you can also use the
exit
command. - Ctrl + L to clear screen; you can also use the
clear
command. - Ctrl + X Ctrl + E to open an
editor to edit command, or V in vi-mode.
Development
Release Strategy
IRedis is built and released by GitHub Actions
. Whenever a tag is pushed to the
master
branch, a new release is built and uploaded to pypi.org, it's very
convenient.
Thus, we release as often as possible, so that users can always enjoy the new
features and bugfixes quickly. Any bugfix or new feature will get at least a
patch release, whereas big features will get a minor release.
Setup Environment
IRedis favors poetry as package
management tool. To setup a develop environment on your computer:
First, install poetry (you can do it in a python's virtualenv):
pip install poetry
Then run (which is similar to pip install -e .
):
poetry install
Be careful running testcases locally, it may flush you db!!!
Development Logs
This is a command-line tool, so we don't write logs to stdout.
You can tail -f ~/.iredis.log
to see logs, the log is pretty clear, you can
see what actually happens from log files.
Catch Up with Latest Redis-doc
IRedis use a git submodule to track current-up-to-date redis-doc version. To
catch up with latest:
- Git pull in redis-doc
- Copy doc files to
/data
:cp -r redis-doc/commands* iredis/data
- Prettier
markdownprettier --prose-wrap always iredis/data/commands/*.md --write
- Check the diff, update IRedis' code if needed.