Skip to content

Commit d7a99fc

Browse files
committed
Add PUBSUB command
1 parent 257711c commit d7a99fc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Redis.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,28 @@ public function psubscribe( $patterns, $callback ) {}
392392
*/
393393
public function publish( $channel, $message ) {}
394394

395+
/**
396+
* A command allowing you to get information on the Redis pub/sub system.
397+
* @param string $keyword String, which can be: "channels", "numsub", or "numpat"
398+
* @param string|array $argument Optional, variant.
399+
* For the "channels" subcommand, you can pass a string pattern.
400+
* For "numsub" an array of channel names
401+
* @return array|int Either an integer or an array.
402+
* - channels Returns an array where the members are the matching channels.
403+
* - numsub Returns a key/value array where the keys are channel names and
404+
* values are their counts.
405+
* - numpat Integer return containing the number active pattern subscriptions.
406+
* @link http://redis.io/commands/pubsub
407+
* @example
408+
* <pre>
409+
* $redis->pubsub('channels'); // All channels
410+
* $redis->pubsub('channels', '*pattern*'); // Just channels matching your pattern
411+
* $redis->pubsub('numsub', array('chan1', 'chan2')); // Get subscriber counts for 'chan1' and 'chan2'
412+
* $redis->pubsub('numpat'); // Get the number of pattern subscribers
413+
* </pre>
414+
*/
415+
public function pubsub( $keyword, $argument ) {}
416+
395417
/**
396418
* Verify if the specified key exists.
397419
*

0 commit comments

Comments
 (0)