/** * @param $mode * @return array */ protected function doTestSetListFunctions($mode) { $res = array(); $key = 'testMultiSet'; $this->redis->del($key); if ($mode == 'multi') { $this->redis->multi(); } else { $this->redis->pipeline(); } $this->redis->sAdd($key, array('value1', 'value2')); $this->redis->sCard($key); $res['set'] = $this->redis->exec(); $this->assertEquals(array(2, 2), $res['set']); $this->assertEquals(2, $this->redis->sCard($key)); $key = 'testMultiList'; $this->redis->del($key); if ($mode == 'multi') { $this->redis->multi(); } else { $this->redis->pipeline(); } $this->redis->lPush($key, 'value1'); $this->redis->lPush($key, 'value2'); $this->redis->lInsert($key, 'after', 'value1', 'value3'); $this->redis->lLen($key); $this->redis->rPop($key); $res['list'] = $this->redis->exec(); $this->assertEquals(array(1, 2, 3, 3, 'value3'), $res['list']); $this->assertEquals(2, $this->redis->lLen($key)); return $res; }
/** * Returns and removes the last element of the list. * * @param string $key * * @return string if command executed successfully BOOL FALSE in case of failure (empty list) * @link http://redis.io/commands/rpop * @example * <pre> * $redis->rPush('key1', 'A'); * $redis->rPush('key1', 'B'); * $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ] * $redis->rPop('key1'); // key1 => [ 'A', 'B' ] * </pre> */ public function rPop($key) { try { return $this->client->rPop($key); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }