Redis Flushall 命令

Redis 服務器

Redis Flushall 命令用于清空整個 Redis 服務器的數據(刪除所有數據庫的所有 key )。

語法

redis Flushall 命令基本語法如下:

redis 127.0.0.1:6379> FLUSHALL 

可用版本

>= 1.0.0

返回值

總是返回 OK 。

實例

redis 127.0.0.1:6379> DBSIZE            # 0 號數據庫的 key 數量
(integer) 9

redis 127.0.0.1:6379> SELECT 1          # 切換到 1 號數據庫
OK

redis 127.0.0.1:6379> DBSIZE         # 1 號數據庫的 key 數量
(integer) 6

redis 127.0.0.1:6379> flushall       # 清空所有數據庫的所有 key
OK

redis 127.0.0.1:6379> DBSIZE         # 不但 1 號數據庫被清空了
(integer) 0

redis 127.0.0.1:6379> SELECT 0       # 0 號數據庫(以及其他所有數據庫)也一樣
OK

redis 127.0.0.1:6379> DBSIZE
(integer) 0

Redis 服務器