valkey-cli
Execute commands on Valkey server
TLDR
Connect to the local server
Connect to a remote server on the default port (6379)
Connect to a remote server specifying a port number
Connect to a remote server specifying a URI
Specify a password
Execute valkey command
Connect to the local cluster
SYNOPSIS
valkey-cli [OPTIONS] [COMMAND [ARGUMENT ...]]
PARAMETERS
-h
Connect to the specified server hostname (default: 127.0.0.1).
-p
Connect to the specified server port (default: 6379).
-a
Authenticate using the given password.
-u
Connect to Valkey using a URI string (e.g., valkey://user:password@host:port/db).
-n
Select the specified database number (default: 0).
--raw
Use raw formatting for replies (no pretty printing).
--latency
Enter latency monitoring mode, showing real-time latency statistics.
--stat
Enter statistics monitoring mode, displaying a summary of server stats every second.
--rdb
Transfer an RDB dump file from the server to the client.
--pipe
Send commands from stdin to the server using the Valkey protocol for efficient bulk operations.
--cluster
Perform cluster-related operations (e.g., check, fix, create, add-node, del-node, reshard).
--eval
Evaluate a Lua script directly on the Valkey server. Requires KEY and ARGV arguments.
--scan
Start in scan mode, simplifying iteration over keys using the SCAN command.
--tls
Use TLS/SSL to connect to the Valkey server for encrypted communication.
DESCRIPTION
valkey-cli is the command-line interface for Valkey, an open-source, in-memory data structure store. It provides a powerful and convenient way to interact with Valkey server instances directly from your terminal. Users can send Valkey commands, monitor server performance, debug scripts, and perform various administrative tasks.
It supports both interactive mode, where you type commands directly, and non-interactive mode, where commands are passed as arguments or piped from standard input. This tool is essential for developers and administrators working with Valkey, offering features like connecting to remote servers, authentication, and specialized modes for tasks such as latency checking, statistical monitoring, and RDB file transfer.
CAVEATS
When using valkey-cli, always consider security implications, especially when connecting to production servers or over insecure networks. Employ authentication (`-a`, `-u`) and TLS (`--tls`) where necessary. Cluster commands (`--cluster`) require a thorough understanding of Valkey Cluster to prevent data loss or service disruption. Operations like `SCAN` or large bulk commands should be used cautiously on active production instances as they can impact performance.
PIPELINING COMMANDS
valkey-cli can execute multiple commands efficiently by pipelining them. This is particularly useful for bulk operations, minimizing network round-trip times.
Example: printf "SET key1 val1\nSET key2 val2\nGET key1\n" | valkey-cli --pipe
LUA SCRIPTING
The `--eval` option enables executing Lua scripts directly on the Valkey server, allowing for atomic multi-command operations and complex server-side logic, significantly extending Valkey's capabilities.
Example: valkey-cli --eval "return redis.call('GET', KEYS[1])" 1 mykey
MONITORING MODES
Specialized modes like `--latency` and `--stat` provide real-time insights into Valkey server performance, which are invaluable for debugging performance issues and optimizing server operations.
HISTORY
Valkey is a Linux Foundation project that emerged in March 2024 as a fork of Redis, prompted by licensing changes introduced by Redis Inc. Consequently, valkey-cli is a direct descendant of redis-cli, inheriting its robust feature set and widely adopted command-line interface design. Its development continues under the Valkey community, committed to maintaining compatibility with existing Redis clients while evolving with new features and improvements specific to the Valkey ecosystem, aiming to provide a fully open-source and permissively licensed alternative to Redis.


