Skip to content

FLUSHDB

The FLUSHDB command is used to clear all keys in the currently selected Redis database.

Terminal window
FLUSHDB

Parameter Description

The FLUSHDB command takes no parameters.

The FLUSHDB command deletes all keys in the currently selected database, but does not affect other databases. This is a very powerful command and should be used with caution.

In redisun, the FLUSHDB command is implemented through the FlushDbCommand class and the flushDb method in the Redisun class.

Redisun redisun = Redisun.create(options -> {
options.setAddress("redis://127.0.0.1:6379");
});
// Clear the current database
boolean result = redisun.flushDb();
System.out.println("FlushDB result: " + result);
  1. FLUSHDB only affects the currently selected database
  2. This is a dangerous operation that deletes all data in the database
  3. The command returns true when executed successfully