Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Created December 16, 2011 09:07
Show Gist options
  • Save Darkflib/1485235 to your computer and use it in GitHub Desktop.
Save Darkflib/1485235 to your computer and use it in GitHub Desktop.
redis subscribe in php
<?php
//just making a note of this here for later use...
//subscribe.php
function f($redis, $chan, $msg) {
switch($chan) {
case 'chan-1':
print "get $msg from $chan\n";
break;
case 'chan-2':
print "get $msg FROM $chan\n";
break;
case 'chan-3':
break;
}
}
ini_set('default_socket_timeout', -1);
$redis = new Redis();
$redis->pconnect('myredisserver.test.com',6378);
$redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f');
print "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment