多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# swoole\_redis->on [TOC] 注册事件回调函数。 ~~~ function swoole_redis->on(string $event_name, callable $callback); ~~~ 目前`swoole_redis`支持2种事件回调函数。`on`方法必须在`connect`前被调用。 ## onClose 当Redis服务器主动关闭连接或者客户端主动调用close关闭连接时,会触发`onClose`事件。 ~~~ function onClose(swoole_redis $redis); ~~~ ## onMessage 当客户端收到来自服务器的订阅消息时触发onMessage事件。 ~~~ function onMessage(swoole_redis $redis, array $message); ~~~