In redis, how do i remove keys?

前端 未结 8 2087
遥遥无期
遥遥无期 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:53

    Another compact one-liner I use to do what you want is:

    redis-cli KEYS "user*" | xargs redis-cli DEL
    
    0 讨论(0)
  • 2020-12-13 08:53

    Using awk, find all matching keys from redis using redis-cli KEYS command and pipe to redis-cli DEL command.

    redis-cli KEYS "user*"  | awk '{ system("redis-cli DEL " $1) }'
    
    0 讨论(0)
提交回复
热议问题