To clear the Redis database, you have two main options:
FLUSHDB
: This command clears the current Redis database.FLUSHALL
: This command clears all databases in the Redis instance.Here's a brief overview of both commands and how to execute them.
FLUSHDB
removes all keys from the currently selected database. To use this command, simply enter it in the Redis CLI:
redis-cli FLUSHDB
You can also use it via a Redis client in your programming language, such as Python with redis-py:
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r.flushdb()
FLUSHALL
removes all keys from all databases within the Redis instance. To use this command, enter it in the Redis CLI:
redis-cli FLUSHALL
You can also use it via a Redis client in your programming language, such as Python with redis-py:
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r.flushall()
Note: Use these commands with caution, as they will delete data permanently.
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.