Chapter

Managing Redis from the console

Operate Redis by hand with redis-cli: connect, find keys, inspect values, delete safely, and monitor the server.

Redis Basics 5 Lessons from courses

About this chapter

The console is where you actually work with a live Redis. In this chapter you will use redis-cli to connect (locally, in Docker, and to a remote host), search and inspect keys safely, delete data without wrecking production, and watch what the server is doing.

Lessons from courses

  1. 1 The redis-cli console Connect to Redis with redis-cli: locally, in Docker, or a remote host. Learn the interactive prompt, one-shot commands, SELECT, and DBSIZE.
  2. 2 Finding keys: SCAN vs KEYS How to list Redis keys by pattern. Why KEYS blocks production, how SCAN with MATCH and COUNT is the safe way, plus the redis-cli --scan shortcut.
  3. 3 Inspecting keys and values Inspect any Redis key from the console: EXISTS, TYPE, TTL, OBJECT ENCODING, MEMORY USAGE, and how to read strings, hashes, lists, sets and sorted sets.
  4. 4 How to delete keys and flush the cache in Redis Delete Redis keys with DEL and UNLINK, remove many by pattern, and delete all keys with FLUSHDB vs FLUSHALL. Plus the danger of flushing production.
  5. 5 Server info and monitoring Watch a live Redis: read INFO memory and keyspace stats, stream commands with MONITOR, check SLOWLOG, and use --stat, --bigkeys, and --latency.
Redis Basics Go to course