Independence Day Offer. Save 25% on Magento Hosting. Sign Up Now.

How to Clear Redis Cache for Magento 2?

Clear Redis Cache for Magento 2

Redis is an open-source in-memory database written in C and is optimized for speed. It is also known as a data structure server as its core data types match the programming languages’ data types, including strings, lists, dictionaries, sets, and sorted sets.

Redis is used for caching as it caches the frequently requested data in memory. It improved the speed and responsiveness of the application.

You can designate the duration of caching and data flow; hence, Redis is a popular distributed caching engine.

Redis on Magento 2

Redis is commonly used on Magento stores for object caching to stabilize the store’s performance. Magento is a popular eCommerce platform used by high-traffic websites and brands.

Redis enables fast back-end caching with cache tag support, so it is also recommended for multi-server hosting.

If you are utilizing Redis for your Magento store, congrats!

Clearing Magento 2 Redis cache, however, is not a one-click solution. Let’s see how to flush the Redis cache.

Flushing Magento Redis Cache

First, make sure that SSH is enabled and you have an active connection with the server. From there, you can use CLI to clear the Redis cache.

If you are on Breeze, you can find the SSH credentials from the dashboard.

Caution: Clearing Redis may affect the object and page caching. Please discuss with the Breeze support team before clearing the Redis cache. Send a message through live chat.

Clear Redis Cache with the Redis-CLI Command

CLI command is the easiest and quickest way to clear Redis cache.

Redis stores the databases separately. You can run different commands to clear keys from the entire database or any single database.

Redis-cli Command Syntax:

The syntax to delete Redis database cache:

redis-cli [database number] [option]

Where:

  • [option]: Enter the databases to delete: Entire or anyone specific database.
  • [database number]: Enter the number of the database you want to clear.

How to Delete All Keys?

Delete all the keys from Redis databases at once by using the following command:

Redis-CLI flushall

In updated Redis 4.0.0, you have to async the process using async parameters in the syntax to avoid blocking the server while deleting the keys.

Redis-CLI flushall async

This is how you delete all the keys from databases.

Deleting Keys from a Specific Database

If you want to clear any single specific database, run the following command:

Redis-CLI flushdb

Use the ‘flushdb’ command without any parameters to clear the database you have selected. 

To specify a database with a number, you can use -n parameters.

Like this:

redis-cli -n [database number] flushdb

Using the Async function will clear the keys in the background without blocking the server. You can use this function with the -n parameter.

redis-cli -n [database number] flushdb async

Conclusion

In this quick tutorial, you learned to clear Redis Cache with CLI. You can use the CLI commands to flush the Redis cache.

For more information, you can read Redis docs.

If you encounter any problem, please leave it in the comment section. And if you are with Breeze, send us the message using live chat.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new plugins, and more. 100% Magento Goodness, a promise!

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

Talk to a sales representative

USA / Worldwide

+1.714.2425683

India

+91.9852704704

We can help you. Right now.

Fast growing merchants depend Breeze for high-performance hosting. Experience counts. Let's get started.

Request demo

Please fill in the details below and we’ll reach out to you with a customized demo of our product!

Get your FREE Image SEO Checklist

Bring more visitors to your image from Google search from the existing images.