From d01d80c42e408eb7877ce0b9a04d0d8caaa89790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 6 Sep 2020 05:39:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Pool/Connection.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 4c117abe..223bda46 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -49,23 +49,25 @@ class Connection extends Pool return; } if ($this->lastTime + 600 < time()) { - $channels = $this->getChannels(); - foreach ($channels as $name => $channel) { - while ($channel->length() > 0) { - $channel->pop(); - $this->desc($name); - } - } + $this->flush(1); } else if ($this->lastTime + 500 < time()) { - $channels = $this->getChannels(); - foreach ($channels as $name => $channel) { - while ($channel->length() > 5) { - $channel->pop(); - $this->desc($name); - } + $this->flush(5); + } + } + + + /** + * @param $retain_number + */ + protected function flush($retain_number) + { + $channels = $this->getChannels(); + foreach ($channels as $name => $channel) { + while ($channel->length() > $retain_number) { + $channel->pop(); + $this->desc($name); } } - }