Skip to content

Commit bd3633e

Browse files
committed
Fix #42
1 parent f18c138 commit bd3633e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Dashboards/Memcached/MemcachedTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ private function mainDashboard(): string {
414414
$keys = $this->getAllKeys();
415415

416416
if (isset($_GET['export_btn'])) {
417-
Helpers::export($keys, 'memcached_backup', fn (string $key): string => base64_encode($this->memcached->getKey(urldecode($key))));
417+
Helpers::export($keys, 'memcached_backup', function (string $key): ?string {
418+
$value = $this->memcached->getKey(urldecode($key));
419+
420+
return $value !== false ? base64_encode($value) : null;
421+
});
418422
}
419423

420424
$paginator = new Paginator($this->template, $keys);

src/Helpers.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,17 @@ public static function export(array $keys, string $filename, callable $value, bo
138138
$json = [];
139139

140140
foreach ($keys as $key) {
141+
$val = $value($key['key']);
142+
if ($val === null) {
143+
continue;
144+
}
145+
141146
$ttl = isset($key['info']['ttl']) && is_int($key['info']['ttl']) ? $key['info']['ttl'] : 0;
142147

143148
$json[] = [
144149
'key' => $key['key'],
145150
'ttl' => $ttl === -1 ? 0 : $ttl,
146-
'value' => $value($key['key']),
151+
'value' => $val,
147152
];
148153
}
149154

0 commit comments

Comments
 (0)