Domen Lušina Domen Lušina - 7 months ago 28
Ruby Question

Redis `CLIENT KILL TYPE pubsub` command equivalent in ruby

I would like to know if there is a ruby equivalent to Redis

CLIENT KILL TYPE pubsub
command or a hack how to do it.

Thank you for help

Answer

If you are talking about rewriting the Redis command to ruby using the redis gem, you can call any command using the call method available on the initiated Redis client. All arguments must be passed in an array together with the command name, such as this:

# first just an example that calling commands like this works:
Redis.new.client.call(["client", "list"])
# => "addr=127.0.0.1:37967 fd=5 name= age=338 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client\n

# the kill command follows:
Redis.new.client.call(["client", "kill", "type", "pubsub"])