Skip to content

Commit d4e50f0

Browse files
committed
add pubsub
1 parent 7c4a954 commit d4e50f0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/redis.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,20 @@ def punsubscribe(*channels)
20002000
end
20012001
end
20022002

2003+
# redis.pubsub(:channels, '*')
2004+
# # => ['channel-1', 'channel-2']
2005+
# redis.pubsub(:numsub, 'channel-1', 'channel-2')
2006+
# # => ['channel-1', 23, 'channel-2', 11]
2007+
# redis.pubsub(:numpat)
2008+
# # => 3
2009+
# Inspect the state of the Pub/Sub subsystem.
2010+
# Possible subcommands: channels, numsub, numpat.
2011+
def pubsub(subcommand, *args)
2012+
synchronize do |client|
2013+
client.call([:pubsub, subcommand, args].flatten)
2014+
end
2015+
end
2016+
20032017
# Watch the given keys to determine execution of the MULTI/EXEC block.
20042018
#
20052019
# Using a block is optional, but is necessary for thread-safety.

0 commit comments

Comments
 (0)