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