Bobcares

Redis flush command – Clear cache quickly

by | Feb 26, 2020

Confused with the Redis flush command? We’ll help you with it.

Usually, we use the flush command to delete all the keys in the Redis cache of web app.

At Bobcares, we often receive queries regarding Redis as part of our Server Management Services.

Today, let us discuss how our Support Engineers clear Redis cache easily for our customers.

 

More about Redis flush command

Before getting detailed into the topic, let’s have a look at the Redis.

Basically, Redis is a server that stores data. And, it primarily works as a key-value store, that can function as a database, cache and a message broker.

Redis databases are always isolated from one another. That is, a command that runs on one database will not affect the data in the other databases.

We use the flush command to delete all keys in a database. Let’s now see how we use this command efficiently.

 

How we use the Redis flush command?

Usually, the Redis databases are numbered from 0 to 15. And, by default, we connect to database 0 when we connect to the Redis instance.

However, we can change the database using the select command.

In general, there are two variants of the flush command, flushall, and flushdb. Let’s now check the usage in detail.

 

1. Flushall

Recently, one of our customers approached us with a query. He wanted to delete all the keys in every database on his Redis server.

Our Support Engineers used the flushall command to do it. This command deletes the keys of all the existing databases including the currently selected one.

Usually, this command never fails. And, an example of how we use the flushall command is shown below.

Redis flush command

2. The flushdb command

Similarly, we can use the flushdb command to delete all the keys of a specified database on the Redis server. We can irreversibly delete all the keys in a single database using this command.

For instance, we select the database 15 and set two keys “key1” and “key2”. And, we use the flushdb command to delete all the keys in that particular database.

Then, if we try to get any of the keys key1 and key2, it will show nil.

redis flush command

Both flushdb and flushall command has the ASYNC option. This option helps to asynchronously delete the keys from the entire database or single database easily.

 

[Need more assistance with this Redis command? – We are available 24/7 to help you.]

 

Conclusion

In short, the flush command helps to delete keys in a database. In today’s writeup, we saw how our Support Engineers do it easily for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.