Skip to main content

Description

Delete all the keys in the currently selected database. This command never fails.
This is a destructive operation that cannot be undone. Use with extreme caution, especially in production environments.

Method Signature

Parameters

object
Optional configuration object:

Return Value

'OK'
Always returns "OK"

Examples

Flush database synchronously

Flush database asynchronously

Clear test data

Safe flush with confirmation

Check size before and after

Async vs Sync

Synchronous (default)

  • Blocks the server until all keys are deleted
  • Suitable for small databases
  • Guarantees database is empty when command returns

Asynchronous

  • Returns immediately
  • Deletion happens in background
  • Suitable for large databases
  • Doesn’t block other operations

See Also

  • del - Delete specific keys
  • dbsize - Get number of keys