$redis = new Redis(); $redis->connect('localhost', 6379); $iterator = null; while (true) { $keys = $redis->scan($iterator, 'test*'); if ($keys === false) {//迭代結束,未找到匹配pattern的key return; } foreach ($keys as $key) { echo $key . PHP_EOL; }
scan 0 match a* count 2