How to delete all keys and everything in Redis
📣 Sponsor
Sometimes we all need a new start - and this goes for Redis too. There are many situations where you will want to entirely wipe all data from Redis. Fortunately, it’s easy to wipe your Redis cache. First, make sure you have redis-cli
installed on your computer. You can do this by installing Redis, which you can learn about here.
After that, it’s only one command to delete all the data in your Redis cache. Note: this will delete EVERYTHING - so make sure you know what you’re doing before you run this command in terminal:
redis-cli flushall
This will delete all databases and all keys. If you only want to delete all keys from the current database, you can run the following command:
redis-cli flushdb
If you’re unsure what database you’re in, you probably only have the one database - however, Redis lets us switch between databases using the following command, where index
is the index of the database you want to select. By default, Redis has 16 databases, with each having a particular index numbered from 0
to 15
.
redis-cli
select <index>
More Tips and Tricks for Redis
- A Complete Guide to Redis Hashes
- How to get all keys in Redis
- Getting Started with Redis and Node.JS
- How to create key value pairs with Redis
- How to Create and Manipulate a List in Redis
- How to delete all keys and everything in Redis
- Make your SSR site Lightning Fast with Redis Cache
- How to Install Redis