8000 Doc for PUB/SUB. · DQPHP/phpredis@c26621e · GitHub
[go: up one dir, main page]

Skip to content

Commit c26621e

Browse files
committed
Doc for PUB/SUB.
10000
1 parent 91256df commit c26621e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.markdown

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,46 @@ $ret = FALSE if x has been modified between the call to WATCH and the call to EX
184184
*/
185185
</pre>
186186

187+
## subscribe
188+
##### Description
189+
Subscribe to channels. Warning: this function will probably change in the future.
190+
##### Parameters
191+
*channels*: an array of channels to subscribe to
192+
*callback*: either a string or an array($instance, 'method_name'). The callback function receives 3 parameters: the redis instance, the channel name, and the message.
193+
##### Example
194+
<pre>
195+
function f($redis, $chan, $msg) {
196+
switch($chan) {
197+
case 'chan-1':
198+
...
199+
break;
200+
201+
case 'chan-2':
202+
...
203+
break;
204+
205+
case 'chan-2':
206+
...
207+
break;
208+
}
209+
}
210+
211+
$redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
212+
</pre>
213+
214+
215+
## publish
216+
##### Description
217+
Publish messages to channels. Warning: this function will probably change in the future.
218+
##### Parameters
219+
*channel*: a channel to publish to
220+
*messsage*: string
221+
##### Example
222+
<pre>
223+
$redis->publish('chan-1', 'hello, world!'); // send message.
224+
</pre>
225+
226+
187227
## exists
188228
##### Description
189229
Verify if the specified key exists.

0 commit comments

Comments
 (0)
0