jeudi 29 janvier 2015

Publish/subscribe in Redis

I really have been struggling understanding the concept of publish/subscribe in Redis I'm looking for an example to make it tangible; I followed their wire protocol example, but they don't make sense to me at all and I don't get the concenpt; I have just copied and pasted their example here; could you please help me understand the logic at least in this example:


Wire protocol example



SUBSCRIBE first second

*3
$9
subscribe
$5
first
:1
*3
$9
subscribe
$6
second
:2


At this point, from another client we issue a PUBLISH operation against the channel named second:



> PUBLISH second Hello
This is what the first client receives:
*3
$7
message
$6
second
$5
Hello


Now the client unsubscribes itself from all the channels using the UNSUBSCRIBE command without additional arguments:



UNSUBSCRIBE
*3
$11
unsubscribe
$6
second
:1
*3
$11
unsubscribe
$5
first
:0


Thanks so much!


Aucun commentaire:

Enregistrer un commentaire