1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- require __DIR__.'/shared.php';
- use Predis\Collection\Iterator;
- $client = new Predis\Client($single_server);
- $client->del('predis:set', 'predis:zset', 'predis:hash');
- for ($i = 0; $i < 5; ++$i) {
- $client->sadd('predis:set', "member:$i");
- $client->zadd('predis:zset', -$i, "member:$i");
- $client->hset('predis:hash', "field:$i", "value:$i");
- }
- echo 'Scan the keyspace matching only our prefixed keys:', PHP_EOL;
- foreach (new Iterator\Keyspace($client, 'predis:*') as $key) {
- echo " - $key", PHP_EOL;
- }
- echo 'Scan members of `predis:set`:', PHP_EOL;
- foreach (new Iterator\SetKey($client, 'predis:set') as $member) {
- echo " - $member", PHP_EOL;
- }
- echo 'Scan members and ranks of `predis:zset`:', PHP_EOL;
- foreach (new Iterator\SortedSetKey($client, 'predis:zset') as $member => $rank) {
- echo " - $member [rank: $rank]", PHP_EOL;
- }
- echo 'Scan fields and values of `predis:hash`:', PHP_EOL;
- foreach (new Iterator\HashKey($client, 'predis:hash') as $field => $value) {
- echo " - $field => $value", PHP_EOL;
- }
|