From 5ddb0d886d17d931bdcdbbcd48bb4e9f0eaca0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Kel=C4=8D=C3=A1k?= Date: Fri, 8 Sep 2023 18:10:08 +0200 Subject: [PATCH] Optimize Memcached keys loading, Fix #25 --- src/Admin.php | 2 +- .../Memcached/Compatibility/CommandTrait.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Admin.php b/src/Admin.php index d88547a..69a69c4 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -15,7 +15,7 @@ use RobiNN\Pca\Dashboards\DashboardInterface; class Admin { - public const VERSION = '1.6.0'; + public const VERSION = '1.6.1'; /** * @var array diff --git a/src/Dashboards/Memcached/Compatibility/CommandTrait.php b/src/Dashboards/Memcached/Compatibility/CommandTrait.php index 95e528e..2f0e3db 100644 --- a/src/Dashboards/Memcached/Compatibility/CommandTrait.php +++ b/src/Dashboards/Memcached/Compatibility/CommandTrait.php @@ -139,7 +139,16 @@ private function commandName(string $command): string { } private function checkCommandEnd(string $command, string $buffer): bool { - return in_array($this->commandName($command), $this->no_end, true) || - preg_match('/^('.implode('|', $this->with_end).')/imu', $buffer); + if (in_array($this->commandName($command), $this->no_end, true)) { + return true; + } + + foreach ($this->with_end as $ending) { + if (str_ends_with($buffer, $ending."\r\n")) { + return true; + } + } + + return false; } }