Applies a hit to the given regions rate limiting.

@param int $count Default 1
@return bool
771298
public function hit($count = 1)
	{
		if (file_exists($this->path))
		{
			$expires = $this->getPathContent('expires');
			if ( ! is_null($expires))
			{
				$hits = $this->getPathContent('hits');
				$hits += $count;
				if ($hits > $this->hits)
				{
					// we reached the limit
					return false;
				}
				$size = $this->writePathContent($expires, $hits);

				return $size !== false;
			}
		}

		// first hit
		$expires = time() + $this->seconds;
		$size    = $this->writePathContent($expires, $count);

		return $size !== false;
	}
199922
public function resetCache($count = 100) {
    $timer = 'reset_cache';
    Timer::start($timer);

    $result = $this->queryFactory->get(self::ENTITY_TYPE)->execute();
    if (empty($result)) {
      $this->logger->info('No cache was found. Nothing to clear.');
      Timer::stop($timer);
      return;
    }

    $this->removeByChunk($result, $count);

    $msg = 'All caches were cleared. [items removed: %items, elapsed time: %time sec.]';
    $this->logger->info(
      $msg,
      [
        '%items' => count($result),
        '%time' => round(Timer::read($timer) / 1000, 1)
      ]
    );

    Timer::stop($timer);
  }
242650
public function select(string $pattern = '', int $count = 100): \Iterator
    {
        $iterator = null;
        while (true) {
            $ret = $this->handle->hScan($this->name, $iterator, $pattern, $count);
            if (false === $ret) {
                break;
            }
            foreach ($ret as $k => $v) {
                yield [$k => $v];
            }
        }
    }
885724
public function right ( $count = 0 ) {
        $this->_currentPosition = array(
                                        $this->_currentPosition[0] + $count,
                                        $this->_currentPosition[1],
                                       );
        return $this;
    }
531474
public function count($count = null)
    {
        if ($count === null) {
            return isset($this->options['count']) ? $this->options['count'] : 0;
        } else {
            $this->options['count'] = $count;
            return $this;
        }
    }
364126
public function each( callable $callback, $count = 1000 )
	{
		if ( is_null( $this->query->orders ) && is_null( $this->query->unionOrders ) )
		{
			$this->orderBy( $this->model->getQualifiedKeyName(), 'asc' );
		}

		return $this->chunk( $count, function ( $results ) use ( $callback )
		{
			foreach ( $results as $key => $value )
			{
				if ( $callback( $value, $key ) === false )
				{
					return false;
				}
			}
		} );
	}
821165
public function setLimit($count, $offset = null)
    {
        $this->_dsql()->limit($count, $offset);

        return $this;
    }
765934
public function update($class, array $counts)
    {
        if (! isset($this->coverage[$class])) {
            $this->coverage[$class] = $counts;

            return;
        }

        foreach ($counts as $line => $status) {
            if (! isset($this->coverage[$class][$line]) || $status > 0) {
                // converts "hits" to "status"
                $status = ! $status ? -1 : ($status > 1 ? 1 : $status);

                $this->coverage[$class][$line] = $status;
            }
        }
    }
143734
function slice ($offset = 0, $count = -1)
  {
    $this->setIterator (new LimitIterator ($this->getIterator (), $offset, $count));
    return $this;
  }
436001
public function ezCount($stat, $count = 1)
    {
        if (! isset($this->config['ez_key'])) {
            throw new Exception('StatHat EZ key not set.');
        }

        // If a prefix is set, prepend it to the stat name.
        if (! empty($this->config['prefix'])) {
            $stat = $this->config['prefix'].$stat;
        }

        $this->post('ez', ['ezkey' => $this->config['ez_key'], 'stat' => $stat, 'count' => $count]);
    }
347420
public function iterNextPage($count = 3)
    {
        if ($this->getPage() == 1 && $this->getPagesCount() >= $count * 2) {
            $count *= 2;
        }
        $pages = [];
        foreach (range(1, $count) as $i) {
            $page = $this->getPage() + $i;
            if ($page <= $this->getPagesCount()) {
                $pages[] = $page;
            }
        }

        return $pages;
    }
138686
public function limit($sql, $count, $offset = 0)
     {
        $count = intval($count);
        if ($count <= 0) {
            // require_once 'Zend/Db/Adapter/Exception.php';
            throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
        }

        $offset = intval($offset);
        if ($offset < 0) {
            /** @see Zend_Db_Adapter_Exception */
            // require_once 'Zend/Db/Adapter/Exception.php';
            throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
        }

        if ($offset == 0) {
            $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql);
        } else {
            $orderby = stristr($sql, 'ORDER BY');

            if (!$orderby) {
                $over = 'ORDER BY (SELECT 0)';
            } else {
                $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
            }

            // Remove ORDER BY clause from $sql
            $sql = preg_replace('/\s+ORDER BY(.*)/', '', $sql);

            // Add ORDER BY clause as an argument for ROW_NUMBER()
            $sql = "SELECT ROW_NUMBER() OVER ($over) AS \"ZEND_DB_ROWNUM\", * FROM ($sql) AS inner_tbl";

            $start = $offset + 1;
            $end = $offset + $count;

            $sql = "WITH outer_tbl AS ($sql) SELECT * FROM outer_tbl WHERE \"ZEND_DB_ROWNUM\" BETWEEN $start AND $end";
        }

        return $sql;
    }
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();
    }
514487
public function chunk( $count, callable $callback )
	{
		$results = $this->forPage( $page = 1, $count )->get();

		while ( count( $results ) > 0 )
		{
			// On each chunk result set, we will pass them to the callback and then let the
			// developer take care of everything within the callback, which allows us to
			// keep the memory low for spinning through large result sets for working.
			if ( call_user_func( $callback, $results ) === false )
			{
				return false;
			}

			$page++;

			$results = $this->forPage( $page, $count )->get();
		}

		return true;
	}
720910
final public function limit($offsetOrCount, $count = null)
    {
        $this->getQuery()->limit($offsetOrCount, $count);
        $this->pagedQuery = true;

        return $this;
    }
300041
public function limit($count, $offset = 0)
    {
        $this->limit = array((int) $count, (int) $offset);

        return $this;
    }
407278
public function limit($count)
    {
        if($count<1 || $count>50){
            throw new \RuntimeException('Limit beyond 1-50 range', ResourceException::LIMIT_BEYOND_RANGE);
        }

        $this->limit = $count;

        return $this;
    }