0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RedisのHashに混入したゴミデータを一括で削除する

Posted at

開発中、Redisに入れてるHashデータにゴミが混入して厄介だったので、消すスクリプトを作った。

参考
http://qiita.com/aki77/items/57bfd7f18c54ba60c0aa

del_hkey.sh
# !/bin/sh

for keyspec in keyspecs to search ; do
	keys=`redis-cli KEYS "$keyspec*"`
	for hkeyspec in `echo $keys`; do
		echo 'key: ' $hkeyspec
		redis-cli HDEL "$hkeyspec" to_delete
	done
done

keyspecs to search: 検索したいキーPREFIXを列挙
to_delete: 消す対象のHASH内キー

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?