Determine if the given key has been "accessed" too many times.

@param  string $key
@param  int $maxAttempts
@param  int $decayMinutes
@return bool
173339
public function tooManyAttempts( $key, $maxAttempts, $decayMinutes = 1 )
	{
		if ( $this->cache->has( $key . ':lockout' ) )
			return true;

		if ( $this->attempts( $key ) > $maxAttempts )
		{
			$this->cache->add( $key . ':lockout', time() + ( $decayMinutes * 60 ), $decayMinutes );

			$this->resetAttempts( $key );

			return true;
		}

		return false;
	}
455794
private function canRetry()
    {
        if ($this->isUnlimitedAttempts()) {
            return true;
        }

        $this->attempts++;

        return $this->attempts < $this->maxAttempts;
    }
685828
public function getExpiry($key)
    {
        $key = $this->getPrefix().$key;
        if (!$this->isInCache($key)) {
            return false;
        }

        return $this->fetchExpirationFromCache($key);
    }
353586
public function expireat($key, $timestamp)
    {
        $this->init();
        $result = $this->driver->expireat($key, $timestamp);
        return (bool)$result;
    }
171385
public function max($key)
    {
        return $this->reduce(function($result, $item) use ($key)
        {
            return (is_null($result) || $item->{$key} > $result) ? $item->{$key} : $result;
        });
    }
315664
protected function buildResponse($key, $maxAttempts)
    {
        $response = new Response('Too Many Attempts.', 429);

        $retryAfter = $this->limiter->availableIn($key);

        return $this->addHeaders(
            $response, $maxAttempts,
            $this->calculateRemainingAttempts($key, $maxAttempts, $retryAfter),
            $retryAfter
        );
    }
556025
public function max($key = null)
    {
        $callback = $this->valueAccessor($key);

        return $this->filter(function ($value) {
            return !is_null($value);
        })->reduce(function ($result, $item) use ($callback) {
            $value = $callback($item);

            return is_null($result) || $value > $result ? $value : $result;
        });
    }
759310
public function detachPersistor($key)
    {
        Assertion::keyExists(
            $this->persistors,
            $key,
            'No registered persistor found.',
            DataAggregatorException::PERSISTOR_NOT_FOUND
        );

        unset($this->persistors[$key]);
    }
1203424
public function isCached($key)
    {
        if ($cachedData = $this->loadCache()) {
            if (isset($cachedData[$key])) {
                if (!$this->isExpired($cachedData[$key]['time'], $cachedData[$key]['expire'])) {
                    return true;
                }
            }
        }
        return false; // If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached
    }
124966
public function rateLimit($key = null) {
		return $key ? (isset($this->rate_limit[$key]) ? $this->rate_limit[$key] : null) : $this->rate_limit;
	}
1106083
protected function buildException($key, $maxAttempts)
    {
        $retryAfter = $this->getTimeUntilNextRetry($key);

        $headers = $this->getHeaders(
            $maxAttempts,
            $this->calculateRemainingAttempts($key, $maxAttempts, $retryAfter),
            $retryAfter
        );

        return new ThrottleRequestsException(
            'Too Many Attempts.', null, $headers
        );
    }
687129
public function isValid(string $key) : bool
    {
        $key  = $this->getActualCacheKey($key);
        $meta = $this->getCacheContents()[$key] ?? [];

        if (empty($meta['expires_at'])) {
            return false;
        }

        return Carbon::now() < Carbon::createFromFormat(self::RFC_7231, $meta['expires_at']);
    }
904724
public function isValid(Memento\Key $key = null, $expired = false)
    {
        $keyPath = $this->getExpiresPath($key);

        // if we are to look for expired files that exist, we must examine ttl instead
        if ($expired === true) {
            $ttlPath = $this->getTtlPath($key);
            $ttlFile = $ttlPath . DIRECTORY_SEPARATOR . self::FILENAME_TTL;

            if (!file_exists($ttlFile)) {
                return false;
            }

            $ttl = intval(file_get_contents($ttlFile));
            if (!is_numeric($ttl)) {
                return false;
            }

            if (time() > $ttl) {
                return false;
            }

            return true;
        }

        $expiresFile = $keyPath . DIRECTORY_SEPARATOR . self::FILENAME_EXPIRES;

        if (!file_exists($expiresFile)) {
            return false;
        }

        $expires = intval(file_get_contents($expiresFile));
        if (!is_numeric($expires)) {
            return false;
        }

        if (time() > $expires) {
            return false;
        }

        return true;
    }
998079
public function acquireLock( $key, $waitTime, $maxTime )
    {
        if ( strlen( $key ) > self::MAX_KEY_LENGTH )
        {
            throw new ezcCacheInvalidKeyException( $key, 'Length > ' . self::MAX_KEY_LENGTH . '.' );
        }

        // add() does not replace and returns true on success. $maxTime is
        // obeyed by Memcache expiry.
        while ( $this->memcache->add( $key, $key, false, $maxTime ) === false )
        {
            // Wait for next check
            usleep( $waitTime );
        }
    }
878222
public function andNotBetween($key, $min, $max)
    {
        $value = sprintf('%s NOT BETWEEN ? AND ?', $key);
        return $this->andAdd($value, [$min, $max]);
    }
469685
protected function expiration($key)
	{
		$lifetime = ini_get("session.gc_maxlifetime");

		$expire = $this->engine->get($key . '_expire');

		// Set prune period
		if ($expire + $lifetime < time())
		{
			$this->engine->delete($key);
			$this->engine->delete($key . '_expire');
		}
		else
		{
			$this->engine->replace($key . '_expire', time());
		}
	}
494372
public function keyExists(string $key): bool
    {
        $result = $this->database->prepare('SELECT * FROM tl_db_cache WHERE cacheKey = ?')->execute($key);

        return $result->numRows > 0;
    }