Recently in the maintenance of a cache with the Redis project, encountered a product needs to eliminate the need to clean up the user's data, because each time to clear a lot of user data, each manual deletion is more cumbersome, and finally adopted a batch script to execute the command of the Purge
The command to be executed begins with a command line in a text file, similar to this one, and named Command.txt
Zrem incr:cjapp1271:day:20150805 1237806859
zrem incr:cjapp1271:day:20150805 723652156
: day:20150805 841597167
zrem incr:cjapp1271:day:20150805 1048187667
Zrem 1091051751
zrem incr:cjapp1271:day:20150805 1264716668
zrem
incr:cjapp1271:day:20150805 Zrem incr:cjapp1271:day:20150805 1264782549
zrem incr:cjapp1271:day:20150805 1264852503 zrem incr:cjapp1271
:d ay:20150805 1264853578
zrem incr:cjapp1271:day:20150805 1264854083
2. Then write the script, named del.sh
#!/bin/sh
host=$1
port=$2
password=$3
cat command.txt |/usr/local/redis/bin/redis-cli-h $host-P $ Port-a $password--pipe
3. Then perform sh des.sh localhost 6379 on the machine where Redis is located, so that all the commands in Command.txt can be executed quickly