Close this search box.

How To Clear Redis Cache from Command Line (2 Easy Methods)

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

How To Clear Redis Cache?

Redis is an open-source, in-memory, data structure store. It can be used as a database, cache, and message broker and supports various data structures such as Strings, Hashes, Lists, Sets, etc. Redis is written in ANSI C and works in most POSIX systems like Linux, *BSD, and OS X without external dependencies. In this article, we will learn how to clear Redis Cache.

Redis is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, and sorted sets. You can run atomic operations on these types like appending to a string; incrementing the value in a hash; pushing to a list; computing set intersection; or getting the member with the highest ranking in a sorted set.

Why would you want to clear Redis Cache?

You might need to clear your Redis cache for one of the following reasons:

  • Your application is running slowly, so you want to check whether your Redis instance is the slow component.
  • You want to clear out a bunch of old data that’s no longer relevant.
  • You’re debugging a problem and want to see whether clearing Redis helps.

The redis-cli command is used to run commands against your Redis instance from your terminal. You need to have SSH access to your server.

If you don’t know how to access server SSH, we’ve written a tutorial where we’ve explained how you can access the terminal using Bitvise -> How To Easily Transfer Files Over SSH Using SCP

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

Clear Redis Cache With the redis-cli Command

The redis-cli is a great option if you have SSH access to your server. Follow these steps to use it:

  • Log into your server via SSH, as explained here
  • Use the redis-cli command to connect to Redis on your server, you can also log in to remote Redis server using redis-cli

Alright, once you are logged into your Redis server, you can now run Redis commands, your terminal should look something like this

how to clear redis cache

Now in this terminal, you can directly run Redis commands.


redis-cli [options]

Since we are already logged into Redis server, we will omit “redis-cli” from some of our commands.

How to Clear Redis Cache from Command Line

We will now clear Redis cache using the flushall command

how to clear redis cache using flushall

As you can see we’ve directly used flushall command and didn’t use the full form (redis-cli flushall) because we are already on Redis server.

This will clear everything from your Redis cache.

Delete Cache of specific Database

flushall command will remove everything from Redis cache, if you want to clear Redis Cache for certain database you first need to find out the database number using:

redis-cli CONFIG GET databases
Note: We’ve omitted redis-cli from our command as we are already in Redis server as explained above

As you now have database numbers you can use the command below to delete entries for certain database

redis-cli -n <database_number> flushdb

Replace <database_number> with your database number.

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

How to Clear Redis Cache from Command Line using async option

From Redis 4.0.0 onwards, keys can be cleared without affecting your server in any way. You can accomplish this by using the flushall command with the async parameter:

redis-cli flushall async

Similarly, if you want to delete from a certain database

redis-cli -n <database_number> flushdb async


In this article, we’ve learned how to clear Redis cache using redis-cli. I’ve also personally noticed that while using Redis Caching with LiteSpeed Cache, it sometimes becomes really slow and when you disable object caching your site becomes normal.

In this case, you can delete and flush your Redis cache and re-enable it. However, if you still have any questions, feel free to ask below.

Related Content: Snapshot vs Backup

Nginx Alternative

Shoaib Khan

Unlock Benefits

Become a Community Member

Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!