Use Redis with the Command Line

In this example, the Redis Command Line Interface (Redis-cli) will be used to show off some of the possible actions that can be performed with Redis.

Prerequisites

The first step is to install the Redis-cli from the official website.  Then load up a a command line tool and run the following command:

Where <cluster node IP> is an IP of any of the master nodes in the cluster.

Once connected, authentication is required:

Where <cluster password> is the password of the created Redis cluster, located on the “Connection Info” tab when viewing the cluster through the Instaclustr Console.

Examples

Setting and Getting keys.

Incrementing a key.

Setting and Getting multiple keys.

Deleting a key (returns 1 (true) if deleted).

Checking if a key exists (returns 1 if true, 0 if false).

Expiring a key (using 5 seconds) and checking expiration (ttl) returning seconds left before expiration.

Troubleshooting

Sometimes after authenticating through the Redis-cli, it is possible that running commands still require authentication.  This is due to the Redis-cli switching to a different node to run commands, and therefore requires authentication through that node as well.  To fix this issue, simply provide the authentication again.

Further Reading

The examples above only give basic usage cases for the redis-cli.  For other languages or more advanced usages (such as using lists, hashes, sets etc) please see the official redis documentation.

Need Support
Learn More

Already have an account?
Login to the Console

Experiencing difficulties on the website or console?
Status page for known incidents


Don’t have an account yet?
Sign up for a free trial

Why sign up?
To experience the ease of creating and managing clusters via the Instaclustr Console.