In this chapter, we’ll look into some of the ways you can connect to
Redis. We’ll begin with the most basic option: Redis’s command-line client,
redis-cli command. Then we’ll look at ways to integrate
Redis with common programming languages such as Ruby and Python.
Often you might find yourself in need of firing a simple Redis query, either to set or change a variable, flush a database, or perhaps take a look at your data. With Redis you can achieve this directly from the command line.
Redis ships with a command line client: redis-cli. Redis-cli is a fully featured
interactive client, supporting line editing, history, and tab
completion. By using
help followed by a Redis command, you
can also get help on how each command works.
You can use redis-cli to connect to a local or remote host Redis server and call commands by passing them as arguments (or piping them in) or by using its interactive mode.
You can get a list of the command line options by typing:
The most typical usage scenarios would be something like the following, to connect to a remote server in interactive mode:
redis-cli -h serverip
The following connects to a local server running on a nondefault port in interactive mode:
redis-cli -p 6380
The following connects to a local server on the default port (6379), executes the INFO command, and returns you to your original shell:
You can also use pipes and output redirection for ...