Get an ordered list of nodes for $key.

@param string   $key    The key to look up.
@param integer  $count  The number of nodes to look up.

@return array  An ordered array of nodes.
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);
    }
1078222
public function sScan($key, $cursor, $pattern = null, $count = null) {
        return $this->_scan('sscan', $key, $cursor, $pattern, $count);
    }
724490
public function sRandMember($key, $count = null, $distinctOnly = true) {
        $payload = ['srandmember', $key];

        if ($count !== null) {
            $payload[] = $distinctOnly ? $count : -$count;
        }

        return $this->send($payload);
    }
751428
private function readLinearRings($count)
    {
        $rings = array();

        for ($i = 0; $i < $count; $i++) {
            $rings[] = $this->readPoints($this->readCount());
        }

        return $rings;
    }
536115
public function each(callable $callback, $count = 1000)
    {
        return $this->chunk($count, function ($results) use ($callback) {
            foreach ($results as $key => $value) {
                if ($callback($value, $key) === false) {
                    return false;
                }
            }
        });
    }
1038609
public function get_key_list() {
        $keys = array();
        foreach ($this->collection as $node) {
            $keys[] = $node->key;
        }
        return $keys;
    }
309125
public function getItems($count = null, $start = 0)
    {
        $matches = $this->gateway->getAll($this->table);
        $matches = $this->applyConditions($matches);
        $matches = $this->applyOrdering($matches);

        if (!empty($this->columns)) {
            $result = $this->applyColumns($matches);
        } else {
            $result = $this->castToEntity($matches);
        }

        return array_slice($result, $start, $count);
    }
955671
public function lists($column, $key = null)
    {
        $this->applyCriteria();

        return $this->model->lists($column, $key);
    }
1079889
public function lrem($key, $count, $value) {
        return $this->returnCommand(['LREM'], $key, [$key, $count, $value]);
    }
222529
public function count($key)
    {
        $connection = $this->getConnection($key);
        $this->writeToRemote(array(
            'cmd' => 'count',
            'key' => $key,
        ), $connection);
        return $this->readFromRemote($connection);
    }
102841
public function getItems($count = null, $start = 0)
    {
        $columns = [];

        foreach ($this->columns as $key => $value) {
            $columns[] = $this->applyTableAlias($value);
        }

        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select(empty($columns) ? $this->applyTableAlias('*') : $columns)
            ->from($this->tableName, $this->tableAlias)
        ;

        $builder = $this->applyConditions($builder);
        $builder = $this->applyOrdering($builder);

        if (!is_null($count)) {
            $builder
                ->setMaxResults($count)
                ->setFirstResult($start)
            ;
        }

        $this->dispatcher->dispatch('onQueryDatabase', new QueryDatabaseEvent($this->entityClass, $builder));

        try {
            $rows = $builder
                ->execute()
                ->fetchAll(\PDO::FETCH_ASSOC)
            ;
        } catch (SyntaxErrorException $e) {
            throw new InvalidOperatorException($e->getMessage(), 0, $e);
        } catch (DBALException $e) {
            throw new EntityNotFoundException();
        }

        foreach ($this->patterns as $column => $pattern) {
            $column = $this->stripTableAlias($column);
            $rows   = array_filter(
                $rows,
                function ($row) use ($column, $pattern) {
                    return preg_match("~{$pattern}~", $row[$column]);
                }
            );
        }

        if (empty($rows)) {
            return [];
        }

        if (empty($this->columns)) {
            $rows = $this->castToEntity($rows);
        }

        if (count($this->columns) == 1 && $this->columns[0] != '*') {
            $result = [];

            foreach ($rows as $match) {
                $result[] = $match[$this->columns[0]];
            }

            return $result;
        }

        return array_values($rows);
    }
65977
public function lists($key, $default = null)
	{
		$results = array();
		foreach ($this->_data as $data)
		{
			array_push($results, $data->get($key));
		}
		return $results;
	}
276808
public function list(int $lastId, int $count)
    {
        $params = [
            'type' => 2,
            'last_seen' => $lastId,
            'count' => $count,
        ];

        return $this->search($params);
    }
97517
public function getSortedNodesBuilder($key = null, $direction = null, $type = null, $limit = null, $locale = null)
    {
        $builder = PublishedNode::translatedIn($locale)
            ->groupBy('nodes.id');

        if ($type)
        {
            $builder->withType($type);
        }

        if ($limit)
        {
            $builder->limit($limit);
        }

        return $builder->sortable($key, $direction);
    }
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);
    }
722031
public function fieldsByKey($key)
	{
		$keys = array();

		if ($this->rows && $this->count())
		{
			foreach ($this->rows as $row)
			{
				$keys[] = $row->$key;
			}
		}

		return $keys;
	}
577792
public function getConstrainedKeysByCount($count, $operator = '>=')
	{
		$associativeTable = $this->associativeTable;
		$associativeLocal = $this->associativeLocal;
		$shifter          = $this->shifter;
		$model            = $this->model;

		return $this->getConstrainedKeys(function($related) use ($count, $associativeTable, $associativeLocal, $shifter, $model, $operator)
		{
			$related->whereEquals($associativeTable . '.' . $shifter, strtolower($model->getModelName()))
			        ->group($shifter)
			        ->group($associativeLocal)
			        ->having('COUNT(*)', $operator, $count);
		});
	}