/** * ZREVRANGEBYLEX key max min [LIMIT offset count] * Available since 2.8.9. * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set * and M the number of elements being returned. * If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)). * @link http://redis.io/commands/zrevrangebylex * * @param string $key * @param string $max * @param string $min * @param int|array $limit * @return string[] List of elements in the specified score range. */ public function zrevrangebylex($key, $max, $min, $limit = null) { $params = [$key, $max, $min]; if ($limit) { $params[] = 'LIMIT'; $params[] = Parameter::limit($limit); } return $this->returnCommand(['ZREVRANGEBYLEX'], $params); }
/** * SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination] * Available since 1.0.0. * Time complexity: O(N+M*log(M)) or O(N) * @link http://redis.io/commands/sort * * @param string $key * @param string|null $pattern * @param int|array|null $limit * @param string|string[]|null $patterns * @param bool|null $asc * @param bool $alpha * @param string|null $destination * @return mixed */ public function sort($key, $pattern = null, $limit = null, $patterns = null, $asc = null, $alpha = false, $destination = null) { $params = [$key]; if ($pattern) { $params[] = 'BY'; $params[] = $pattern; } if ($limit) { $params[] = 'LIMIT'; $params[] = Parameter::limit($limit); } if ($patterns) { foreach ((array) $patterns as $p) { $params[] = 'GET'; $params[] = $p; } } if (isset($asc)) { $params[] = $asc ? 'ASC' : 'DESC'; } if ($alpha) { $params[] = 'ALPHA'; } if ($destination) { $params[] = 'STORE'; $params[] = $destination; } return $this->returnCommand(['SORT'], $params); }
/** * ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] * Available since 2.2.0. * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set * and M the number of elements being returned. * If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)). * @link http://redis.io/commands/zrevrangebyscore * * @param string $key * @param string $max * @param string $min * @param bool|false $withscores * @param string|array|null $limit * @return string[]|array list of elements in the specified score range (optionally with their scores). */ public function zrevrangebyscore($key, $max, $min, $withscores = false, $limit = null) { $params = [$key, $max, $min]; if ($withscores) { $params[] = 'WITHSCORES'; } if ($limit) { $params[] = 'LIMIT'; $params[] = Parameter::limit($limit); } return $this->returnCommand(['ZREVRANGEBYSCORE'], $params, $withscores ? ResponseParser::PARSE_ASSOC_ARRAY : null); }