• TCP socket
redis-cli -h my-host -p 1234 -a mypassword
  • UNIX socket
redis-cli -s <path/to/unix.sock>

Select a database

  • Default db is 0
redis> SELECT <index>

List all keys

redis> KEYS *
  • With types
for KEY in $(redis-cli KEYS "*" | cut -d " " -f 2); do echo -en "$KEY - "; redis-cli TYPE "$KEY"; done

Show type of keys

redis> type "key"

Read keys

  • Normal key
redis> GET "key"
  • set key
redis> SMEMBERS "key"
  • hash key
redis> HGETALL "key"

Write keys

  • Normal key
redis> SET "key" "value"
  • set key
redis> SADD "key" "value"
  • hash key
redis> HSET "key" "field" "value"

Delete a key

redis> DEL "key"

Drop database

redis> FLUSHDB

Save changes to disk

redis> SAVE
  • You can define a periodic interval in redis.conf
save 60 99999

Monitor realtime requests

redis> MONITOR