LoginSignup
6
6

More than 5 years have passed since last update.

Redisで複数のキーを一気に削除するコマンド

Last updated at Posted at 2016-11-15

redis-cliではkeysに対して*(ワイルドカード)が使えるので、削除する場合も同様に良い感じにできるできるだろうと思って、ドキュメントを眺めたところなかったので調べてみた。

環境

  • Redis 3.2.0

コマンド

$ redis-cli KEYS "*" | xargs redis-cli DEL

"*"の部分を一致するパターンに変更することで、パターンに一致するキーのみ削除することが可能になる。

参考資料

How to atomically delete keys matching a pattern using Redis - Stack Overflow

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6