Created
March 13, 2020 05:29
-
-
Save naveed125/b41a55d35147df9b15e6914b5b08ed15 to your computer and use it in GitHub Desktop.
Redis pubsub consumer example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// uses Predis see https://github.com/nrk/predis | |
$client = new Predis\Client(); | |
// connect to the local redis server | |
$client->connect(); | |
// wait for messages on channel and print them on screen | |
echo("Waiting for messages on channel.\n"); | |
$loop = $client->pubSubLoop(); | |
$loop->subscribe("channel"); | |
foreach($loop as $message) { | |
if($message->kind == "message") { | |
echo("Received: {$message->payload}\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment