[フレーム]
Docs Pricing
Login Book a meeting Try Redis

FLUSHALL

Syntax
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 Enterprise and Redis Cloud compatibility

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.

It is possible to use one of the following modifiers to dictate the flushing mode explicitly:

FLUSHALL SYNC
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
import redis
r = redis.Redis(decode_responses=True)
res1 = r.flushall(asynchronous=False)
print(res1) # >>> True
res2 = r.keys()
print(res2) # >>> []
res3 = r.info()
print(res3)
# >>> {'redis_version': '7.4.0', 'redis_git_sha1': 'c9d29f6a',...}
Python Quick-Start
import { createClient } from 'redis';
const client = createClient();
await client.connect().catch(console.error);
const res1 = await client.flushAll('SYNC'); // or ASYNC
console.log(res1); // OK

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

const res3 = await client.info();
console.log(res3)
// # Server
// redis_version:7.4.0
// redis_git_sha1:c9d29f6a
// redis_git_dirty:0
// redis_build_id:4c367a16e3f9616
// redis_mode:standalone
// ...

await client.close();
Node.js Quick-Start
importjava.util.Set;importredis.clients.jedis.Jedis;importredis.clients.jedis.UnifiedJedis;import staticorg.junit.jupiter.api.Assertions.assertEquals;publicclass CmdsServerMgmtExample{publicvoidrun(){UnifiedJedisjedis=newUnifiedJedis("redis://localhost:6379");StringflushAllResult1=jedis.flushAll();System.out.println(flushAllResult1);// >>> OKSet<String>flushAllResult2=jedis.keys("*");System.out.println(flushAllResult2);// >>> []// Note: you must use the `Jedis` class to access the `info`// command rather than `UnifiedJedis`.Jedisjedis2=newJedis("redis://localhost:6379");StringinfoResult=jedis2.info();// Check the first 8 characters of the result (the full `info` string// is much longer than this).System.out.println(infoResult.substring(0,8));// >>> # Serverjedis2.close();jedis.close();}}
Java-Sync Quick-Start
package example_commands_test
import (
	"context"
	"fmt"
	"github.com/redis/go-redis/v9"
)
func ExampleClient_cmd_flushall() {
	ctx := context.Background()
	rdb := redis.NewClient(&redis.Options{
		Addr: "localhost:6379",
		Password: "", // no password docs
		DB: 0, // use default DB
	})
	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) // >>> []
}
func ExampleClient_cmd_info() {
	ctx := context.Background()
	rdb := redis.NewClient(&redis.Options{
		Addr: "localhost:6379",
		Password: "", // no password docs
		DB: 0, // use default DB
	})
	infoResult, err := rdb.Info(ctx).Result()
	if err != nil {
		panic(err)
	}
	// Check the first 8 characters (the full info string contains
	// much more text than this).
	fmt.Println(infoResult[:8]) // >>> # Server
}
Go Quick-Start

Notes

Behavior change history

Redis Enterprise and Redis Cloud compatibility

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

Return information

History

RATE THIS PAGE
Back to top ↑

AltStyle によって変換されたページ (->オリジナル) /