Skip to content

Commit ed7e10d

Browse files
Added cluster specific test for SCAN
1 parent 51f5796 commit ed7e10d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/RedisClusterTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,26 @@ public function testTime() {
154154
}
155155

156156
public function testScan() {
157-
$this->markTestSkipped(); // this will be implemented
157+
$i_key_count = 0;
158+
$i_scan_count = 0;
159+
160+
/* Have scan retry for us */
161+
$this->redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
162+
163+
/* Iterate over our masters, scanning each one */
164+
foreach ($this->redis->_masters() as $arr_master) {
165+
/* Grab the number of keys we have */
166+
$i_key_count += $this->redis->dbsize($arr_master);
167+
168+
/* Scan the keys here */
169+
$it = NULL;
170+
while ($arr_keys = $this->redis->scan($it, $arr_master)) {
171+
$i_scan_count += count($arr_keys);
172+
}
173+
}
174+
175+
/* Our total key count should match */
176+
$this->assertEquals($i_scan_count, $i_key_count);
158177
}
159178

160179
// Run some simple tests against the PUBSUB command. This is problematic, as we

0 commit comments

Comments
 (0)