Skip to content

Commit f0c25a2

Browse files
Better ducmentation for SCAN
Fixes phpredis#1151
1 parent 520e06a commit f0c25a2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.markdown

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,13 +1013,14 @@ _**Description**_: Scan the keyspace for keys
10131013
##### *Example*
10141014
~~~
10151015
$it = NULL; /* Initialize our iterator to NULL */
1016-
$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); /* retry when we get no keys back */
1017-
while($arr_keys = $redis->scan($it)) {
1016+
do {
1017+
// Use global option $redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); to ignore empty results
1018+
$arr_keys = $redis->scan($it);
10181019
foreach($arr_keys as $str_key) {
10191020
echo "Here is a key: $str_key\n";
10201021
}
1021-
echo "No more keys to scan!\n";
1022-
}
1022+
} while ($it > 0);
1023+
echo "No more keys to scan!\n";
10231024
~~~
10241025

10251026
### object

0 commit comments

Comments
 (0)