Skip to content

Commit 143b973

Browse files
committed
Switch to SCAN command if KEYS is disabled
1 parent 4c30d50 commit 143b973

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/Dashboards/Redis/RedisTrait.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ public function getAllKeys(): array {
360360
$filter = Http::get('s', '*');
361361
$this->template->addGlobal('search_value', $filter);
362362

363-
if (isset($this->servers[$this->current_server]['scansize'])) {
364-
$keys_array = $this->redis->scanKeys($filter, (int) $this->servers[$this->current_server]['scansize']);
363+
if (isset($this->servers[$this->current_server]['scansize']) || !$this->isCommandSupported('KEYS')) {
364+
$scansize = (int) ($this->servers[$this->current_server]['scansize'] ?? 1000);
365+
$keys_array = $this->redis->scanKeys($filter, $scansize);
365366
} else {
366367
$keys_array = $this->redis->keys($filter);
367368
}
@@ -375,6 +376,18 @@ public function getAllKeys(): array {
375376
return $this->keysTableView($keys);
376377
}
377378

379+
private function isCommandSupported(string $command): bool {
380+
try {
381+
$commands = $this->redis->rawCommand('COMMAND');
382+
$command_names = array_column($commands, 0);
383+
$is_supported = in_array(strtolower($command), $command_names, true);
384+
} catch (Exception) {
385+
$is_supported = false;
386+
}
387+
388+
return $is_supported;
389+
}
390+
378391
/**
379392
* @param array<int|string, mixed> $keys
380393
*

0 commit comments

Comments
 (0)