Created a cron job that deletes specific keys in Redis.
Sample key: "\xac\xed\x00\x05t\x00\x15test"
Using bash and redis-cli it seems that keys with HEX values cannot be properly parsed and deleted:
Code below:
host=${1:-}
port=${2:-6379}
database=${3:-0}
pattern=${4:-"Test"}
cursor=-1
keys=""
echo "Starting to delete"
while [ $cursor -ne 0 ]; do
if [ $cursor -eq -1 ]
then
cursor=0
fi
reply=`redis-cli -h $host -p $port SCAN $cursor MATCH $pattern`
cursor=`expr "$reply" : '\([0-9]*[0-9 ]\)'`
keys=${reply##[0-9]*[0-9 ]}
echo "$keys"
redis-cli -h $host -p $port DEL $keys
done