From 14523c96e2aef9ab466a90f670569c1f152af696 Mon Sep 17 00:00:00 2001 From: zhoudw <zhoudw@infobird.com> Date: Tue, 21 Dec 2021 14:24:05 +0800 Subject: [PATCH] 删除key --- config/config.php | 4 ++-- ws_server.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index aaccd7a..de61f87 100644 --- a/config/config.php +++ b/config/config.php @@ -2,7 +2,7 @@ /* * @Author: your name * @Date: 2021-12-15 11:33:00 - * @LastEditTime: 2021-12-21 13:40:02 + * @LastEditTime: 2021-12-21 14:23:49 * @LastEditors: Please set LastEditors * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @FilePath: /websocket/config/config.php @@ -15,7 +15,7 @@ ), //本机WebSocket服务配置 'server_config' => array( - 'allow_ip' => '120.25.156.26:58003', + 'allow_ip' => '120.25.156.26:58004', 'host' => '0.0.0.0', 'port' => '9501', ), diff --git a/ws_server.php b/ws_server.php index 6c22850..a47255d 100644 --- a/ws_server.php +++ b/ws_server.php @@ -28,6 +28,13 @@ ]); if (!$this->redis) { $this->redis = new Redis(); + $this->redis->connect($this->redis_config['host'],$this->redis_config['port'] ); + $host = $this->server_config['allow_ip']; + $keyList = $this->redis->keys("*{$host}*"); + foreach ($keyList as $key => $value) { + $this->redis->del($value); + } + $this->redis->close(); } $this->server->on('start', function (Swoole\WebSocket\Server $server) { echo "Websocket Server is started at ws://".$this->server_config['host'].":".$this->server_config['port']."\n"; -- Gitblit v1.8.0