shell 匹配刪除指定前綴的keyredis
#! /bin/bash rediscom="/redis/src/redis-cli -a auth -h redis.host -n 0"; `$rediscom keys LM*`|xargs `$rediscom del `
shell 匹配修改key的有效期shell
#! /bin/bash rediscom=""; scannum=0; endnum=1; expire=86400; while [ $scannum -ne $endnum ] do endnum=1; arr=(`$rediscom scan $scannum` ); scannum=${arr[0]}; for key in ${arr[@]:1} do echo `${rediscom} expire ${key} $expire`; done; done;
redis 的逐出策略收到maxmemory的限制,超過這個數有一些key就會被逐出內存釋放空間bash