How to Delete everything in Redis Cache cluster – Guidelines

delete keys Redis

Today in this article we shall see how to delete everything in Redis cache server.

We shall see various useful commands and understand their behavior to achieve the same.

Most of the below commands are executed using redis-cli. If you are using any language-specific libraries, then you can very much code the respective method for deleting the cache.

Today in this article, we will cover below aspects,

Below I have used sudo apt-get commands for the Redis server and Redis-CLI-specific commands for the demonstration purpose.


Delete single key in Redis from current database

Command

DEL key [key ...]

Example

del 102

or

Delete multiple keys in Redis

del 101,102,103 

delete everything in Redis

Delete all keys in Redis the database

Command

FLUSHALL [ASYNC|SYNC]

Example

FLUSHALL

delete keys Redis cluster

FLUSHALL – Delete all the keys of all the existing databases synchronously by default, not just the currently selected one.

  • ASYNC: flushes the databases asynchronously
  • SYNC: flushes the databases synchronously

delete all keys in redis cluster

Command

FLUSDB [ASYNC|SYNC]

Example

FLUSHDB async

Or

FLUSHDB 

FLUSHDB command – Delete all the keys of the currently selected DB. 

FLUSHDB will synchronously flush all keys from the database.

Do you have any comments or ideas or any better suggestions to share?

Please sound off your comments below.

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

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