107 Star 765 Fork 269

开源技术小栈 / lua-nginx-redis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
nohupRedisNotify.php 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
#! /usr/bin/php
<?php
require_once './RedisInstance.class.php';
RedisInstance::getInstance()->setOption(\Redis::OPT_READ_TIMEOUT,-1);
RedisInstance::getInstance()->psubscribe(array('__keyevent@0__:expired'), 'psCallback');
RedisInstance::getInstance()->psubscribe(array('__keyevent@0__:expired'),function ($redis, $pattern, $chan, $msg){
// 回调函数,这里写处理逻辑
$messageId = explode(':',$msg);
switch($messageId[0]){
case '4001':
curlPost('http://127.0.0.1',array('id'=>$messageId[1]));
break;
case '4002':
curlPost('http://127.0.0.1',array('id'=>$messageId[1]));
break;
case '4003':
curlPost('http://127.0.0.1',array('id'=>$messageId[1]));
break;
default:
curlPost('http://127.0.0.1',array('id'=>$msg));
break;
}
});
function curlPost($url, $curlPost)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
$return_str = curl_exec($curl);
curl_close($curl);
return $return_str;
}
Lua
1
https://gitee.com/Tinywan/lua-nginx-redis.git
git@gitee.com:Tinywan/lua-nginx-redis.git
Tinywan
lua-nginx-redis
lua-nginx-redis
master

搜索帮助