Skip to content

Commit 8553df2

Browse files
committed
Memcached fixes.
1 parent f04ff67 commit 8553df2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ services:
9191
9292
- PHP >= 8.2 (Use [v1 branch](https://github.com/RobiNN1/phpCacheAdmin/tree/v1.x) if you need support for >=7.4)
9393
- Redis server >= 3.0.0
94-
- Memcached server >= 1.4.31. If you do not see the keys, you need to enable `lru_crawler`. SASL is not supported because there is no way to get the keys.
94+
- Memcached server >= 1.4.31 (ideally >= 1.5.19 to see more data). If you do not see the keys, you need to enable `lru_crawler`. SASL is not supported because there is no way to get the keys.
9595

9696
> It is not necessary to have all dashboards enabled.
9797

src/Dashboards/Memcached/MemcachedTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private function viewKey(): string {
112112
}
113113

114114
$info = $this->memcached->getKeyMeta($key);
115-
$ttl = $info['exp'];
115+
$ttl = $info['exp'] ?? null;
116116
$ttl = $ttl === 0 ? -1 : $ttl;
117117

118118
if (isset($_GET['export'])) {
@@ -135,8 +135,8 @@ private function viewKey(): string {
135135
return $this->template->render('partials/view_key', [
136136
'key' => $key,
137137
'value' => $formatted_value,
138-
'ttl' => Format::seconds($ttl),
139-
'size' => Format::bytes($info['size']),
138+
'ttl' => $ttl ? Format::seconds($ttl) : null,
139+
'size' => isset($info['size']) ? Format::bytes($info['size']) : null,
140140
'encode_fn' => $encode_fn,
141141
'formatted' => $is_formatted,
142142
'edit_url' => Http::queryString(['ttl'], ['form' => 'edit', 'key' => $key]),

src/Dashboards/Memcached/PHPMem.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,21 @@ public function getKey(string $key): string|false {
157157
/**
158158
* Get key meta-data.
159159
*
160+
* This command requires Memcached server >= 1.5.19
161+
*
162+
* @link https://github.com/memcached/memcached/wiki/ReleaseNotes1519
163+
*
160164
* @return array<string, string|int>
161165
*
162166
* @throws MemcachedException
163167
*/
164168
public function getKeyMeta(string $key): array {
165169
$raw = $this->runCommand('me '.$key);
170+
171+
if ($raw === 'ERROR') {
172+
return [];
173+
}
174+
166175
$raw = preg_replace('/^ME\s+\S+\s+/', '', $raw); // Remove `ME keyname`
167176

168177
return $this->parseLine($raw);

0 commit comments

Comments
 (0)