DEV Community

Cover image for How to delete all keys and everything in Redis
Johnny Simpson
Johnny Simpson

Posted on • Originally published at fjolt.com

8 2

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 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs