How do I delete everything in Redis?

前端 未结 22 1048
无人共我
无人共我 2020-11-28 17:18

I want to delete all keys. I want everything wiped out and give me a blank database.

Is there a way to do this in Redis client?

22条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 17:47

    This works for me: redis-cli KEYS \* | xargs --max-procs=16 -L 100 redis-cli DEL

    It list all Keys in redis, then pass using xargs to redis-cli DEL, using max 100 Keys per command, but running 16 command at time, very fast and useful when there is not FLUSHDB or FLUSHALL due to security reasons, for example when using Redis from Bitnami in Docker or Kubernetes. Also, it doesn't require any additional programming language and it just one line.

提交回复
热议问题