Use Valkey with the Command Line

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

Prerequisites

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

If you have password authentication enabled:

If you have disabled password authentication:

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

Where <password> is the password for the user you are connecting as. By default instaclustr Valkey instances will be created with the user icvalkey.

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 valkey-cli, it is possible that running commands still require authentication.  This is due to the valkey-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 valkey-cli.  For other languages or more advanced usages (such as using lists, hashes, sets etc) please see the official valkey documentation.

By Instaclustr Support
Need Support?
Experiencing difficulties on the website or console?
Already have an account?
Need help with your cluster?
Contact Support
Why sign up?
To experience the ease of creating and managing clusters via the Instaclustr Console
Spin up a cluster in minutes