Use Redis with the Command Line

Menu

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.

FREE TRIAL

Spin up a cluster in less
than 5 minutes.
(No credit card required)

Sign Up Now
Close

Site by Swell Design Group