diff --git a/src/Abuse/Adapters/TimeLimit/Redis.php b/src/Abuse/Adapters/TimeLimit/Redis.php index fc4cb8fc64..19602613a2 100644 --- a/src/Abuse/Adapters/TimeLimit/Redis.php +++ b/src/Abuse/Adapters/TimeLimit/Redis.php @@ -84,38 +84,22 @@ class Redis extends TimeLimit * * @param int|null $offset * @param int|null $limit - * @return array + * @return array */ public function getLogs(?int $offset = null, ?int $limit = 25): array { - $cursor = 0; - $matches = []; - $pattern = self::NAMESPACE . '__*'; + // TODO limit potential is SCAN but needs cursor no offset + $cursor = null; + $keys = $this->redis->scan($cursor, self::NAMESPACE . '__*', $limit); + if (!$keys) { + return []; + } - do { - $result = $this->redis->scan($cursor, $pattern, $limit); - - // Early return if scan failed - if (!is_array($result)) { - return []; - } - - [$newCursor, $keys] = $result; - $cursor = (int)$newCursor; - - if (!empty($keys)) { - $values = $this->redis->mget($keys); - if (is_array($values)) { - /** @var array */ - $combinedArray = array_combine($keys, $values); - if ($combinedArray !== false) { - $matches = array_merge($matches, $combinedArray); - } - } - } - } while ($cursor > 0 && (!$limit || count($matches) < $limit)); - - return $matches; + $logs = []; + foreach ($keys as $key) { + $logs[$key] = $this->redis->get($key); + } + return $logs; } /**