Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How to Clear a Specific Redis Database Cache

Warning

FLUSHDB permanently deletes all keys in the selected Redis database. Verify host and database index before running this command.

Prerequisites

  • Network access to the Redis server
  • redis-cli installed
  • Correct Redis database index

Install client tools (if needed):

sudo apt update && sudo apt install redis-tools

Steps

  1. Connect to the Redis server and select the target database:
redis-cli -h prod-xxxx.amazonaws.com -d 2
  1. Run flush command:
flushdb async
  1. Verify response:
OK

Replace 2 with your target database index (0-based).

If you need to clear all databases (higher risk), use flushall async instead.