How to delete all keys and everything in Redis

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 …

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>

Print Share Comment Cite Upload Translate
APA
Johnny Simpson | Sciencx (2024-03-29T11:11:36+00:00) » How to delete all keys and everything in Redis. Retrieved from https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/.
MLA
" » How to delete all keys and everything in Redis." Johnny Simpson | Sciencx - Saturday September 17, 2022, https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/
HARVARD
Johnny Simpson | Sciencx Saturday September 17, 2022 » How to delete all keys and everything in Redis., viewed 2024-03-29T11:11:36+00:00,<https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/>
VANCOUVER
Johnny Simpson | Sciencx - » How to delete all keys and everything in Redis. [Internet]. [Accessed 2024-03-29T11:11:36+00:00]. Available from: https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/
CHICAGO
" » How to delete all keys and everything in Redis." Johnny Simpson | Sciencx - Accessed 2024-03-29T11:11:36+00:00. https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/
IEEE
" » How to delete all keys and everything in Redis." Johnny Simpson | Sciencx [Online]. Available: https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/. [Accessed: 2024-03-29T11:11:36+00:00]
rf:citation
» How to delete all keys and everything in Redis | Johnny Simpson | Sciencx | https://www.scien.cx/2022/09/17/how-to-delete-all-keys-and-everything-in-redis/ | 2024-03-29T11:11:36+00:00
https://github.com/addpipe/simple-recorderjs-demo