get sets with score.

@param  string $key
@param  int    $start
@param  int    $limit
@param  bool   $with_scores
@return array
358055
public function getSortedSets($key, $start = 0, $limit = 20, $with_scores = true)
    {
        return $this->getSortedSetsAsc($key, $start, $limit, $with_scores);
    }
352264
public function hmset($key) {

        $set     = $this->getKey($collection, $key, []);
        $args    = func_get_args();

        for ($i=1; $i<count($fields); $i++){
            $field = $args[$i];
            $value = isset($args[($i+1)]) ? $args[($i+1)] : null;

            $set[$field] = $value;
            $i = $i + 1;
        }

        $this->setKey($collection, $key, $set);
    }
1292795
public function getTermsAsync($limit = null, $starting_after = null, $ending_before = null)
    {
        return $this->getTermsAsyncWithHttpInfo($limit, $starting_after, $ending_before)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }
1200452
public function getTotalResult($start, $limit, $sortBy, $sortOrder, $params)
    {
        $results = $this->findAll($start, $limit, $sortBy, $sortOrder, $params);

        return count($results);
    }
623285
protected function buildException(string $key, int $limit)
    {
        $after = $this->limiter->availableIn($key);
        $exception = new TooManyRequestsHttpException($after, 'Rate limit exceeded.');
        $exception->setHeaders($this->getHeaders($key, $limit, $after, $exception->getHeaders()));

        return $exception;
    }
997657
public function fetch($key) : Collection
    {
        $extr = [];
        foreach ($this->list as $list) {
            if (is_array($list) && key_exists($key, $list)) {
                $extr[] = $list[$key];
            }
        }

        return self::from(...$extr);
    }
1283593
public static function getStats($key, $options = [])
    {
        // Merge options with default options
        $options = array_merge([
            // Show nested (boolean)
            'nested'         => true,
            // Prefix for nested items (string)
            'nested_prefix'  => '|-- ',
            // Max key length (int)
            'max_key_length' => 100,
        ], $options);

        // If item does not exist
        if (!isset(self::$collection[$key])) {
            return 'Unknow item in with key: ' . $key;
        }

        // Get item
        $item = self::$collection[$key];

        // Get item result
        $itemResult          = 'N/A';
        $itemResultFormatted = 'N/A';
        if (isset($item['start']) && isset($item['stop'])) {
            $itemResult          = (($item['stop'] - $item['start']) * 1000);
            $itemResultFormatted = self::formatMiliseconds($itemResult, 4, self::$forceDisplayUnit);
        }

        // Variable for output
        $output = '';

        // Prep key for output
        $outputName = '';
        $outputName .= ($options['nested'] ? str_repeat($options['nested_prefix'], $item['level']) : '');
        $outputName .= $item['key'];
        if (mb_strlen($outputName) > $options['max_key_length']) {
            $outputName = '~' . mb_substr($item['key'], -($options['max_key_length'] - 1));
        }

        // Add item stats
        $output .= str_pad($outputName, ($options['max_key_length'] + (strlen($outputName) - mb_strlen($outputName))), ' ');
        $output .= ' | ';
        $output .= str_pad($itemResultFormatted, 20, ' ', ($itemResult == 'N/A' ? STR_PAD_RIGHT : STR_PAD_LEFT));

        if (php_sapi_name() != 'cli' && is_array(self::$colorThreshold) && count(self::$colorThreshold)) {
            krsort(self::$colorThreshold);
            foreach (self::$colorThreshold as $value => $color) {
                if (is_numeric($itemResult) && $itemResult >= $value) {
                    $output = '<span style="color: ' . $color . ';">' . $output . '</span>';
                }
            }
        }

        return $output;
    }
754363
public function zRevRange($key, $start = 0, $stop = -1, $withScores = false) {
        return $this->_zRange('zrevrange', $key, $start, $stop, $withScores);
    }
1246002
protected function apcu_fetch($key, &$success = null)
    {
        /*
         * $key can also be numeric, in which case APC is able to retrieve it,
         * but will have an invalid $key in the results array, and trying to
         * locate it by its $key in that array will fail with `undefined index`.
         * I'll work around this by requesting those values 1 by 1.
         */
        if (is_array($key)) {
            $nums = array_filter($key, 'is_numeric');
            if ($nums) {
                $values = array();
                foreach ($nums as $k) {
                    $values[$k] = $this->apcu_fetch((string) $k, $success);
                }

                $remaining = array_diff($key, $nums);
                if ($remaining) {
                    $values += $this->apcu_fetch($remaining, $success2);
                    $success &= $success2;
                }

                return $values;
            }
        }

        if (function_exists('apcu_fetch')) {
            return apcu_fetch($key, $success);
        } else {
            return apc_fetch($key, $success);
        }
    }
434439
public function limit($start, $offset = null) {
        $this->_limit = ' LIMIT ' . $start;
        
        if (!is_null($offset)) {
            $this->_limit .= ', ' . $offset;    
        }
        
        return $this;
    }
617078
public function getSortedSetsDesc($key, $start = 0, $limit = 20, $with_scores = true)
    {
        return $this->driver->zRevRangeByScore($key, '+inf', 0, ['limit' => [$start, $limit], 'withscores' => $with_scores]);
    }
64466
public function zRange($key, $start = 0, $stop = -1, $withScores = false) {
        return $this->_zRange('zrange', $key, $start, $stop, $withScores);
    }
1315769
public function getDataObjects($limit = 0, $start = 0) {

        $pagination = \PaginatedList::create($this->toArrayList())
			->setPageLength($limit)
			->setPageStart($start)
			->setTotalItems($this->getTotalResults())
			->setLimitItems(false);
		return $pagination;
    }
3606
protected function buildException(string $key, int $limit, bool $headers)
    {
        $after = $this->limiter->availableIn($key);

        $exception = new ThrottlingException($after, 'Rate limit exceeded.');

        $headers = $this->getHeaders($key, $limit, $headers, $after, $exception->getHeaders());

        $exception->setHeaders($headers);

        return $exception;
    }
549393
public function getNodes($key, $count = 5)
    {
        // Degenerate cases
        if ($this->_nodeCount < $count) {
            throw new Exception('Not enough nodes (have ' . $this->_nodeCount . ', ' . $count . ' requested)');
        }
        if ($this->_nodeCount == 0) {
            return array();
        }

        // Simple case
        if ($this->_nodeCount == 1) {
            return array($this->_nodes[0]['n']);
        }

        $hash = $this->hash(serialize($key));

        // Find the first point on the circle greater than $hash by binary search.
        $low = 0;
        $high = $this->_pointCount - 1;
        $index = null;
        while (true) {
            $mid = (int)(($low + $high) / 2);
            if ($mid == $this->_pointCount) {
                $index = 0;
                break;
            }

            $midval = $this->_pointMap[$mid];
            $midval1 = ($mid == 0) ? 0 : $this->_pointMap[$mid - 1];
            if ($midval1 < $hash && $hash <= $midval) {
                $index = $mid;
                break;
            }

            if ($midval > $hash) {
                $high = $mid - 1;
            } else {
                $low = $mid + 1;
            }

            if ($low > $high) {
                $index = 0;
                break;
            }
        }

        $nodes = array();
        while (count($nodes) < $count) {
            $nodeIndex = $this->_pointMap[$index++ % $this->_pointCount];
            $nodes[$nodeIndex] = $this->_nodes[$this->_circle[$nodeIndex]]['n'];
        }
        return array_values($nodes);
    }
1168909
public function search(string $query, $limit = 30, $start = 0, $sort = null)
    {
        if ($query == '*.*' && $limit == 30 && $start == 0 && $sort == 'lastupdated desc') {
            $result = $this->fetchFromCache();

            if (null === $result) {
                $result = $this->search->search($query, $limit, $start, $sort);
                $this->saveToCache($result);
            }

            return $result;
        } else {
            return $this->search->search($query, $limit, $start, $sort);
        }
    }
978159
public function zRangeByScore($key, $min = 0, $max = -1, $withScores = false, $offset = null, $count = null) {
        $payload = ['zrangebyscore', $key, $min, $max];

        if ($withScores) {
            $payload[] = 'WITHSCORES';
        }

        if ($offset !== null && $count !== null) {
            $payload[] = 'LIMIT';
            $payload[] = $offset;
            $payload[] = $count;
        }

        return $this->send($payload, function ($response) use ($withScores) {
            if ($withScores) {
                $result = [];

                for ($i = 0, $count = \count($response); $i < $count; $i += 2) {
                    $result[$response[$i]] = $response[$i + 1];
                }

                return $result;
            }

            return $response;
        });
    }