FLUSHALL

FLUSHALL [ASYNC | SYNC]
Available since:
Redis Open Source 1.0.0
Time complexity:
O(N) where N is the total number of keys in all databases
ACL categories:
@keyspace, @write, @slow, @dangerous,
Compatibility:
Redis Software and Redis Cloud compatibility
Note:
This command's behavior varies in clustered Redis environments. See the multi-key operations page for more information.

Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.

By default, FLUSHALL will synchronously flush all the databases. Starting with Redis 6.2, setting the lazyfree-lazy-user-flush configuration directive to yes changes the default flush mode to asynchronous.

Full delete: Delete all keys from all databases using FLUSHALL (dangerous operation, supports ASYNC/SYNC modes, clears RDB file)
FLUSHALL SYNC
res1 = r.flushall(asynchronous=False)
print(res1) # >>> True

res2 = r.keys()
print(res2) # >>> []

const res1 = await client.flushAll('SYNC'); // or ASYNC
console.log(res1); // OK

const res2 = await client.keys('*');
console.log(res2); // []

        String flushAllResult1 = jedis.flushAll();
        System.out.println(flushAllResult1); // >>> OK

        Set<String> flushAllResult2 = jedis.keys("*");
        System.out.println(flushAllResult2); // >>> []
	flushAllResult1, err := rdb.FlushAll(ctx).Result()

	if err != nil {
		panic(err)
	}

	fmt.Println(flushAllResult1) // >>> OK

	flushAllResult2, err := rdb.Keys(ctx, "*").Result()

	if err != nil {
		panic(err)
	}

	fmt.Println(flushAllResult2) // >>> []

Optional arguments

ASYNC | SYNC

Flush asynchronously (ASYNC) or synchronously (SYNC). The default is set by the lazyfree-lazy-user-flush configuration directive.

Details

  • An asynchronous FLUSHALL command only deletes keys that were present at the time the command was invoked. Keys created during an asynchronous flush will be unaffected.
  • This command does not delete functions.
  • Other than emptying all databases (similar to FLUSHDB), this command clears the RDB persistence file, aborts any snapshot that is in progress, and, if the save config is enabled, saves an empty RDB file.

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
✅ Standard
❌ Active-Active*
✅ Standard
❌ Active-Active
*Can use the Active-Active flush API request.

Return information

History

  • Starting with Redis version 4.0.0: Added the ASYNC flushing mode modifier.
  • Starting with Redis version 6.2.0: Added the SYNC flushing mode modifier. The default flush behavior is now configurable using the lazyfree-lazy-user-flush configuration directive.
RATE THIS PAGE
Back to top ↑