In redis, how do i remove keys?

前端 未结 8 2085
遥遥无期
遥遥无期 2020-12-13 07:56

I want to remove keys that match \"user*\".

how do I do that in redis command line?

8条回答
  •  醉梦人生
    2020-12-13 08:28

    Further to orangeoctopus' answer, you don't need the echo and pipe, you can pass commands as arguments into redis-cli. This means you can do

    for key in `redis-cli "KEYS" "user*" | awk '{print $1}'`
     do redis-cli "DEL" "$key"
    done
    

提交回复
热议问题