redis-cli Command Reference: Flags, Usage & CI Examples
redis-cli is the command-line client for a Redis server.
redis-cli connects to a Redis server and runs commands interactively or as one-shot arguments. In CI it seeds keys, flushes state, and provides a readiness healthcheck.
Common flags and usage
- -h <host> / -p <port>: server host and port (default 6379)
- -a <password>: authenticate (or set REDISCLI_AUTH)
- -n <db>: select a logical database number
- ping: returns PONG when the server is up
- -u redis://...: connect with a single URI
- --scan: iterate keys without blocking like KEYS
Example
shell
until [ "$(redis-cli -h localhost -p 6379 ping)" = "PONG" ]; do
echo "waiting for redis..."; sleep 1
done
redis-cli -u "${REDIS_URL}" set warmed 1In CI
redis-cli ping is the standard healthcheck: loop until it returns PONG before tests connect. Pass auth via REDISCLI_AUTH rather than -a on the command line to keep the password out of the process list.
Key takeaways
- redis-cli runs Redis commands as one-shot args or interactively.
- A ping that returns PONG is the canonical readiness healthcheck.
- Prefer REDISCLI_AUTH over -a to hide the password from ps.
Related guides
mongosh Command Reference: Flags, Usage & CI ExamplesReference for mongosh: the connection string, --eval, --quiet, authSource, and a CI example that pings a Mong…
psql Command Reference: Flags, Usage & CI ExamplesReference for the psql PostgreSQL client: connection flags, -c and -f, PGPASSWORD, ON_ERROR_STOP, and a CI ex…
pg_isready Command Reference: Flags, Exit Codes & CI ExamplesReference for pg_isready: -h, -p, -t, -q, the 0/1/2/3 exit codes, and a CI wait loop that blocks until a Post…