redis键过期通知

  1. 作者QQ:67065435 QQ群:821635552

  2. 本站内容全部为作者原创,转载请注明出处!

  3. Redis键过期通知

    <?php
    class PublishMsg
    {
        public function index()
        {
            $redis = new Redis();
            $redis->connect("192.168.1.163", "6379");
            $redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
            $redis->subscribe(["__keyevent@0__:expired"], [$this, "getMsg"]);
        }
    
        public function getMsg($redis, $channel, $msg)
        {
            $chapter_key = $msg;
            $chapter_info = explode(':', $chapter_key);
            if (count($chapter_info) != 2 || $chapter_info[0] != 'xxx' || !is_numeric($chapter_info[1])) {
                return false;
            }
            echo $msg;
            echo "\n";
            return true;
        }
    }
    
    $publish_msg = new PublishMsg();
    $publish_msg->index();
    
Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2020-08-19 14:05:41

results matching ""

    No results matching ""