Terima kasih @martinczerwiIni adalah versi non-rekursif:
function scanAllForMatch($pattern)
{
$cursor = 0;
do {
list($cursor, $keys) = Redis::scan($cursor, 'match', $pattern);
foreach ($keys as $key) {
yield $key;
}
} while ($cursor);
}