redis监听过期事件通知

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

redis过期通知阻塞模式 php代码使用swoole多线程监听

redis.conf 中配置 设置定期后通知

notify-keyspace-events "Ex"
$redis = new Redis();
$redis->pconnect('127.0.0.1', 6379);
$redis->select(1);//监听db1
$redis->setOption(\Redis::OPT_READ_TIMEOUT, -1);
$redis->psubscribe(['__keyevent@1__:expired'], function ($redis, $pattern, $chan, $msg) {
	echo "1Payload: $msg\n\n";
	echo($res);
});

转载于:https://my.oschina.net/Alexmyj/blog/1863175

你可能感兴趣的:(redis监听过期事件通知)