1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- require_once 'SharedConfigurations.php';
- function zpop($client, $zsetKey) {
- $element = null;
- $options = array(
- 'cas' => true,
- 'watch' => $zsetKey,
- 'retry' => 3,
-
- );
- $txReply = $client->multiExec($options, function($tx)
- use ($zsetKey, &$element) {
- @list($element) = $tx->zrange($zsetKey, 0, 0);
- if (isset($element)) {
- $tx->multi();
- $tx->zrem($zsetKey, $element);
- }
- });
- return $element;
- }
- $redis = new Predis\Client($single_server, 'dev');
- $zpopped = zpop($redis, 'zset');
- echo isset($zpopped) ? "ZPOPed $zpopped" : "Nothing to ZPOP!", "\n";
- ?>
|