redis-cli: Basic

Connect and Select Database

redis-cli [-h <hostname>] [-p <port>] [-n <db_number>] [command]

Defaults:
    hostname: 127.0.0.1
    port: 6379
    db_number: 0

Examples

$ redis-cli
127.0.0.1:6379>


$ redis-cli -h my.host
my.host:6379> select 1
OK
my.host:6379[1]>


$ redis-cli -h my.host -n 1
my.host:6379[1]>

Getting Info

See: redis.io/commands/info

redis-cli INFO [section]

$ redis-cli INFO

$ redis-cli
127.0.0.1:6379> INFO


$ redis-cli INFO server
$ redis-cli INFO memory
$ redis-cli INFO clients
$ redis-cli INFO keyspace
$ redis-cli INFO replication

$ redis-cli -h my.host INFO clients
$ redis-cli -h my.host INFO clients | grep connected_client
$ redis-cli -h my.host INFO memory | grep human
$ redis-cli -h my.host INFO replication | grep role

DBSIZE

Return the number of keys in the currently-selected database.

$ redis-cli DBSIZE

$ redis-cli -n 1 DBSIZE
$ redis-cli -h my.host -n 1 DBSIZE

Leave a Comment

Your email address will not be published. Required fields are marked *