|
1 | | - |
2 | 1 | #! /usr/bin/php |
3 | 2 | <?php |
4 | 3 | require_once './RedisInstance.class.php'; |
5 | | -require_once './Gateway.class.php'; |
6 | 4 | RedisInstance::getInstance()->setOption(\Redis::OPT_READ_TIMEOUT,-1); |
7 | 5 | RedisInstance::getInstance()->psubscribe(array('__keyevent@0__:expired'), 'psCallback'); |
8 | | -// 回调函数,这里写处理逻辑 |
9 | | -function psCallback($redis, $pattern, $chan, $msg) |
10 | | -{ |
11 | | - $messageId = explode(':',$msg); |
12 | | - //print_r($msg); |
13 | | - //echo $messageId[0]."<br/>"; |
14 | | - //echo $messageId[1]; |
15 | | - //die; |
16 | | - //RedisInstance::getInstance()->set("channelXode",$messageId); |
17 | | - switch($messageId[0]){ |
18 | | - case '4001': |
19 | | - curlPost('http://127.0.0.1',array('id'=>$messageId[1])); |
20 | | - break; |
21 | | - case '4002': |
22 | | - curlPost('http://127.0.0.1',array('id'=>$messageId[1])); |
23 | | - break; |
24 | | - case '4003': |
25 | | - curlPost('http://127.0.0.1',array('id'=>$messageId[1])); |
26 | | - break; |
27 | | - default: |
28 | | - curlPost('http://127.0.0.1',array('id'=>$msg)); |
29 | | - break; |
30 | | - } |
31 | | -} |
| 6 | +RedisInstance::getInstance()->psubscribe(array('__keyevent@0__:expired'),function ($redis, $pattern, $chan, $msg){ |
| 7 | + // 回调函数,这里写处理逻辑 |
| 8 | + $messageId = explode(':',$msg); |
| 9 | + switch($messageId[0]){ |
| 10 | + case '4001': |
| 11 | + curlPost('http://127.0.0.1',array('id'=>$messageId[1])); |
| 12 | + break; |
| 13 | + case '4002': |
| 14 | + curlPost('http://127.0.0.1',array('id'=>$messageId[1])); |
| 15 | + break; |
| 16 | + case '4003': |
| 17 | + curlPost('http://127.0.0.1',array('id'=>$messageId[1])); |
| 18 | + break; |
| 19 | + default: |
| 20 | + curlPost('http://127.0.0.1',array('id'=>$msg)); |
| 21 | + break; |
| 22 | + } |
| 23 | +}); |
32 | 24 |
|
33 | 25 | function curlPost($url, $curlPost) |
34 | 26 | { |
|
0 commit comments