Esempio n. 1
0
 /**
  * Returns and removes the first|last element of the list.
  *
  * {{{
  *   Lists::pop('incoming'); // gets first element from list `incoming`
  *   Lists::pop('incoming', true); // gets first element from list `incoming` or waits until
  *                                    it is present in a blocking manner
  *   Lists::pop('incoming', false, array('last' => true)); // gets last element from list
  * }}}
  *
  * @see li3_redis\storage\Redis::listPop()
  * @see li3_redis\storage\Redis::getKey()
  * @param string $key The key to uniquely identify the item in redis
  * @param boolean $blocking set to true, if you want to wait until an item appears in list
  * @param array $options array with additional options, see Redis::getKey()
  *     - `last`: set to true, if last element should be returned, defaults to false
  * @return bool|string the first|last element from the list, false if non-existent
  * @filter
  */
 public static function pop($key, $blocking = false, array $options = array())
 {
     $defaults = array('namespace' => static::$namespace);
     $options += $defaults;
     $params = compact('key', 'blocking', 'options');
     return static::_filter(__METHOD__, $params, function ($self, $params) {
         return Redis::listPop($params['key'], $params['blocking'], $params['options']);
     });
 }