Skip to content

Commit 0b973eb

Browse files
committed
Optimize Memcached
1 parent 983b283 commit 0b973eb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Dashboards/Memcached/MemcachedTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ private function getAllKeys(): array {
210210
$time = time();
211211

212212
foreach ($this->all_keys as $key_data) {
213+
$key_data = $this->memcached->parseLine($key_data);
214+
213215
$key = $key_data['key'];
214216

215217
if (stripos($key, $search) !== false) {

src/Dashboards/Memcached/PHPMem.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,18 @@ public function isConnected(): bool {
120120
*/
121121
public function getKeys(): array {
122122
$raw = $this->runCommand('lru_crawler metadump all');
123-
$lines = array_filter(explode("\n", trim($raw)), static fn ($line): bool => !empty($line) && $line !== 'END');
124-
$keys = [];
123+
$lines = explode("\n", $raw);
124+
array_pop($lines);
125125

126-
foreach ($lines as $line) {
127-
$keys[] = $this->parseLine($line);
128-
}
129-
130-
return $keys;
126+
return $lines;
131127
}
132128

133129
/**
134130
* Convert raw key line to an array.
135131
*
136132
* @return array<string, string|int>
137133
*/
138-
private function parseLine(string $line): array {
134+
public function parseLine(string $line): array {
139135
$data = [];
140136

141137
foreach (\explode(' ', $line) as $part) {

0 commit comments

Comments
 (0)