Home > Database > Redis > How to clear data in redis

How to clear data in redis

silencement
Release: 2019-06-17 15:10:11
Original
19424 people have browsed it

How to clear data in redis

The Redis Flushall command is used to clear the data of the entire Redis server (delete all keys of all databases).

Syntax

The basic syntax of the redis Flushall command is as follows:

redis 127.0.0.1:6379> FLUSHALL
Copy after login

Available versions

>= 1.0.0

Return value

Always returns OK.

Example

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
Copy after login

The above is the detailed content of How to clear data in redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template