Commit 1f6afbbd authored by liuyuzhen's avatar liuyuzhen

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into lyz

parents e650e460 f240cf42
<?php
//发布
$redis = new Redis();
$redis->connect('192.168.1.201', 6379);
$message='happy New Year';
$ret=$redis->publish('pushcenter',$message);
<?php
//订阅
ini_set('default_socket_timeout', -1); //不超时
$redis = new Redis();
$redis->connect('192.168.1.201', 6379);
$result=$redis->subscribe(array('pushcenter'), 'callback');
function printTest($meg){
$len=10;
for($i=0;$i<$len;$i++){
sleep(1);
echo $meg."\r\n";
}
}
function callback($instance,$channelName,$message){
printTest($message);
}
<?php
/**
* 推送10秒推送一次
* 推送10秒推送一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require APPLICATION_PATH . '/scripts/crontab/common.php';
error_reporting(E_ALL ^ E_NOTICE);
// redis 没有设置密码
$conf = \Yaf\Registry::get('config')->get('redis.database.params');
$redis=new Redis();
$redis->connect($conf['host'], $conf['port']);
if(!empty($conf['password'])){
$redis->auth($conf['password']);
}
$result=$redis->subscribe(array('pushcenter'), 'callback');
function printTest($meg){
echo $meg;
}
function callback($instance,$channelName,$message){
printTest($message);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment