true, // Initialize with support for CAS operations 'watch' => $zsetKey, // Key that needs to be WATCHed to detect changes ); $tx = $client->multiExec($options); @list($element) = $tx->zrange($zsetKey, 0, 0); if (isset($element)) { $tx->multi(); // With CAS, MULTI *must* be explicitly invoked. $tx->zrem($zsetKey, $element); $tx->exec(); } return $element; } $redis = new Predis_Client($single_server, 'dev'); $zpopped = zpop($redis, 'zset'); echo isset($zpopped) ? "ZPOPed $zpopped" : "Nothing to ZPOP!", "\n"; ?>