Inspect and clear Redis safely

Databases

Inspect Redis keys and clear targeted cache data.

  1. 1

    Connect

    redis-cli -h <host> -p <port>
  2. 2

    Check key count

    DBSIZE
  3. 3

    Scan keys

    SCAN 0 MATCH <prefix>* COUNT 100
  4. 4

    Delete key

    DEL <key>
  5. 5

    Flush DB (destructive)

    FLUSHDB

Common mistakes

  • Using FLUSHALL/FLUSHDB in production without explicit approval.

Related commands: redis-cli, SCAN, DEL