Redis CLI Cheatsheet

This is a super light weight reference for the interactive mode of the Redis CLI tool. I really just want to use it to explore what data is in Redis, so the emphasis is on getting in and listing data rather than setting values.

Documentation for all the Redis commands is at

Starting the CLI in interactive mode

Connect to a locally running instance of Redis and start the interactive REPL:

$ redis-cli

Configure hints:

:set hints
:set nohints

Get help for a command:

help [command]

Query Config

List all sorts of useful config:


Select a database (key space)

Show the max number of databases this server is configured to host:

config get databases

List the available databases:

info "keyspace"

Select the redis database to use:

select [index]

Find out what’s in a key space

List all the keys in the currently selected keyspace:

keys *

Batch list keys. Pass 0 the first time, then the cursor number given by Redis next time:

scan [cursor|0]

Query key value type

Find out what data structure a key holds:

type [keyname]

String types

Getting, setting and removing keys holding string values:

get [keyname]
set [keyname] [value]
del [keyname]

Set types

List all members of a key holding a set data structure:

smembers [keyname]

Hash types

List all keys and values of a hash data structure:

hgetall [keyname]

List types

List all elements of a list data structure:

LRANGE key 0 -1

-1 refers to the last element of the list.

Expiring keys

set [keyname] ex [ttl in s]
ttl [keyname]
expire [keyname] [ttl]