@param string $key
@param string $cursor
@param string $pattern
@param int    $count

@return Promise
@yield array
431636
public function hScan($key, $cursor, $pattern = null, $count = null) {
        return $this->_scan('hscan', $key, $cursor, $pattern, $count);
    }
104561
private function query($count)
    {
        $this->applyQueryFilters();

        if ($this->hasTranslating()) {
            $this->applyTranslationFilter();
        }

        if ($this->orderBy()) {
            $this->query = $this->query->orderBy(
                                $this->orderBy(),
                                $this->sortBy()
                            );
        }

        if ($count) {
            return $this->query->count();
        }

        if ($this->perPage > 0) {
            return $this->query->paginate($this->perPage);
        }

        return $this->query->get();
    }
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);
    }
1095992
protected function firstKeySegments($key, $count=1)
    {
        $segments = explode('.', $key);
        return implode('.', array_slice($segments, 0, $count));
    }
391174
public function eachById(callable $callback, $count = 1000, $column = null, $alias = null)
    {
        return $this->chunkById($count, function ($results) use ($callback) {
            foreach ($results as $key => $value) {
                if ($callback($value, $key) === false) {
                    return false;
                }
            }
        }, $column, $alias);
    }
200475
public function keys($pattern = null) {

        $keys = array();
        $stmt = $this->connection->query("SELECT `key` FROM ".$this->table." ORDER BY `key`;");
        $res  = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        if (!$pattern) {

            foreach ($res as $record) {
                $keys[] = $record["key"];
            }

        } else {

            $matcher = function_exists('fnmatch') ? 'fnmatch': function($pattern, $string){
                return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
            };

            foreach ($res as $record) {
                if($matcher($pattern, $record["key"])) {
                    $keys[] = $record["key"];
                }
            }
        }

        return $keys;
    }
708297
public static function replace( $string, $arr, $count = null ) 
	{
		return str_replace( array_keys( $arr ), array_values( $arr ), $string, $count );
	}
44774
public function scan($cursor, $pattern = null, $count = null) {
        $params = [$cursor];
        if ($pattern) {
            $params[] = 'MATCH';
            $params[] = $pattern;
        }
        if ($count) {
            $params[] = 'COUNT';
            $params[] = $count;
        }
        return $this->returnCommand(['SCAN'], null, $params);
    }
804496
public function getFileCount( $pattern = NULL )
	{
		$count	= 0;
		foreach( $this->getFileList( $pattern ) as $entry )
			$count++;
		return $count;
	}
222529
public function count($key)
    {
        $connection = $this->getConnection($key);
        $this->writeToRemote(array(
            'cmd' => 'count',
            'key' => $key,
        ), $connection);
        return $this->readFromRemote($connection);
    }
752263
public function newLine($count = 1) {

        // send out any escaping to implement anything sitting in the desired state
        $this->outputEscapeSequence();

        // if the $count is greater than one
        if (is_int($count) && $count > 1) {

            // send out the \n $count times
            for ($i=0; $i<$count; ++$i) {

                // echo the newline character
                $this->output("\n");
            }

        } else {
            // the parameter might be one or something crazy, just output one
            // echo the new line character
            $this->output("\n");
        }

        // fire the handler that indicates the cursor is sent to the left margin
        $this->carriageReturn();

        // chaining
        return $this;
    }
249195
public static function replacePatternWithKeyword(array $subject, $keyword, $pattern = '$1')
    {
        $parameters = [];
        foreach ($subject as $param) {
            if (is_array($param)) {
                $parameters[] = self::replacePatternWithKeyword($param, $keyword, $pattern);
            } else {
                $parameters[] = str_replace($pattern, $keyword, $param);
            }
        }

        return $parameters;
    }
601816
function list_keys($pattern = '')
    {
        $this->load_pgp_driver();
        $result = $this->pgp_driver->list_keys($pattern);

        if ($result instanceof enigma_error) {
            self::raise_error($result, __LINE__);
        }

        return $result;
    }
887299
public function sscan(&$Iterator, $field, $pattern = null, $count = null)
    {
        return $this->__call('sscan', [$field, &$Iterator, $pattern, $count]);
    }
868063
public function memoryUsage($key, $count = null) {
        return $this->returnCommand(['MEMORY', 'USAGE'], [$key], isset($count) ? [$key, 'SAMPLES', $count] : [$key]);
    }
1101669
public function replaceCallback(callable $callback, $subject, $limit = -1, & $count = null)
	{
		$this->clean();
		return preg_replace_callback($this->pattern, $callback, $subject, $limit, $count);
	}
425685
public function stream_read($count) {
    assert(isset($this->client));
    return $this->client->read($count);
  }