Is there a way I can flush my redis db using redis?
I'm looking for something like redis.flushdb()
or redis.flushall()
flushdb() # Delete all keys of currently selected database instance. r. flushall() # Delete all keys of entire database.
To clear data of a DCS Redis 4.0 or 5.0 instance, you can run the FLUSHDB or FLUSHALL command in redis-cli, use the data clearing function on the DCS console, or run the FLUSHDB command on Web CLI. To clear data of a Redis Cluster instance, run the FLUSHDB or FLUSHALL command on every shard of the instance.
There are two major commands to delete the keys present in Redis: FLUSHDB and FLUSHALL. We can use the Redis CLI to execute these commands. The FLUSHDB command deletes the keys in a database. And the FLUSHALL command deletes all keys in all databases.
In Redis you can flush cache/database and delete all keys from all databases or from the particular database only using FLUSHALL and FLUSHDB commands. To delete all keys from all Redis databases, use the FLUSHALL command. To delete all keys of the selected Redis database only, use the FLUSHDB commnad.
Redis-py actually has this functionality:
import redis r = redis.Redis() r.flushdb()
Yes, flushdb()
and flushall()
both exist.
check out this page, you will find them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With