Skip to content

Instantly share code, notes, and snippets.

@naveed125
Created March 13, 2020 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naveed125/b41a55d35147df9b15e6914b5b08ed15 to your computer and use it in GitHub Desktop.
Save naveed125/b41a55d35147df9b15e6914b5b08ed15 to your computer and use it in GitHub Desktop.
Redis pubsub consumer example
<?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