redis-cli --scan --pattern users:* | xargs redis-cli del
# Or if you have a cluster:
redis-cli --scan --pattern users:* | xargs -L redis-cli -c del
This one is working for big number of keys:
EVAL "local keys = redis.call('keys', ARGV[1])
for i=1,#keys,5000 do
redis.call('del', unpack(keys, i, math.min(i+4999, #keys)))
end
return keys" 0 prefix:*