<?php
//require_once dirname(__FILE__).'/class/RedisClass.class.php';
function init_redis(){
$redis = new Redis();
$redis->connect('127.0.0.1','6379');
return $redis;
}
//键值过期是通知
function psubscribe($callback){
$redis = init_redis();
$redis->psubscribe(array('__keyevent@*__:expired'),$callback);
}
//订阅频道
function subscribe($callback){
$redis = init_redis();
$redis->subscribe(array('sunsun'),$callback);
}
//键值过期的回调函数
function redisCallback($redis, $pattern, $channel, $message)
{
var_dump($redis);
var_dump($pattern);
var_dump($channel);
var_dump($message);
}
//订阅的回调函数
function redisCallbacks($redis, $channel, $message)
{
var_dump($redis);
var_dump($channel);
var_dump($message);
}
psubscribe('redisCallback');
subscribe('redisCallbacks');