Tries to get the result for the given api request from the cache.

@param RequestBag $requestBag

@return bool|mixed False or the actual result from cache.
5435
public static function getFromCache(RequestBag $requestBag)
    {
        // check if we have cache in settings
        if (!$requestBag->getApiConfig()->get('Cache', false) || $requestBag->getMethodData()['cache']['ttl'] <= 0) {
            return false;
        }

        $instance = new self($requestBag);

        return $instance->getCallbackResultFromCache();
    }
918258
public function bindRequestParameters(ParameterBag $bag = null) {

		if($bag) {
			$this->requestValues = $bag;
		}

		else {
			if($this->request->getMethod() == 'GET') {
				$this->requestValues = $this->request->query;
			}
			else {
				$this->requestValues = $this->request->request;
			}
		}

		// set form element values

		foreach($this->elements as $name => $element) {
			if(is_array($element)) {
				$this->setElementArrayRequestValue($name);
			}
			else {
				$this->setElementRequestValue($element);
			}
		}

		return $this;
	}
533175
public function getResponse(\BearFramework\App\Request $request)
    {
        $requestPath = (string) $request->path;
        $requestMethod = $request->method;
        foreach ($this->data as $route) {
            foreach ($route[0] as $pattern) {
                $matches = null;
                preg_match('/^(?:(?:((?:[A-Z]+\|){0,}[A-Z]+) )?)(.*+)/', $pattern, $matches);
                $patternMethods = '|' . ($matches[1] === '' ? 'GET' : $matches[1]) . '|';
                if (strpos($patternMethods, '|' . $requestMethod . '|') === false) {
                    continue;
                }
                $patternPath = $matches[2];
                if (preg_match('/^' . str_replace(['/', '?', '*'], ['\/', '[^\/]+?', '.+?'], $patternPath) . '$/u', $requestPath) === 1) {
                    foreach ($route[1] as $callable) {
                        ob_start();
                        try {
                            $response = call_user_func($callable, $request);
                            ob_end_clean();
                        } catch (\Exception $e) {
                            ob_end_clean();
                            throw $e;
                        }
                        if ($response instanceof App\Response) {
                            return $response;
                        }
                    }
                    // continue searching
                }
            }
        }
        if ($request->method === 'HEAD') {
            $getRequest = clone($request);
            $getRequest->method = 'GET';
            $response = $this->getResponse($getRequest);
            if ($response instanceof App\Response) {
                $response->content = '';
                return $response;
            }
        }
        return null;
    }
628362
public function matchRequest($requestedRoute, $httpMethod)
    {
        // Iterate through each route that has been registered
        foreach ($this->routes as $route => $callback) {
            
            // Convert the route to a regex pattern
            $routeRx = preg_replace(
                        '%/:([^ /?]+)(\?)?%',
                        '/\2(?P<\1>[^ /?]+)\2',
                    $route);
            
            // If the route also defined a HTTP method to match against, 
            // append the requested route with the request's method
            $routeMethod = strstr($route, ':', true);
            if ($routeMethod && substr($routeMethod, -1) != '/') {
                $requestPrepend = strtolower($httpMethod).':';
            } else {
                $requestPrepend = '';
            }
            
            // Check for a regex match with the requested route. Store the 
            // matches in a variable so the Request instance can be informed.
            if (preg_match('%^' . $routeRx . '$%',
                            $requestPrepend.$requestedRoute,
                            $uriParams)
                ) {
                // A route match was found
                
                // Before returning true, store the params 
                // that were matched, and store the matched route.
                foreach ($uriParams as $key => $value) {
                    if (is_numeric($key)) unset($uriParams[$key]);
                }
                $this->params = (object) $uriParams;
                $this->matched = $route;
                
                return true;
            }
        }
        
        // No matches caught
        return false;
    }
64925
public function process(RequestInterface $request): bool
    {
        if (!$request->getMethod()->isGet()) {
            return false;
        }

        if ($request->getUrl()->getQueryString() === null) {
            return false;
        }

        return $this->doProcess($request->getQueryParameters());
    }
1167944
protected function performPingRequest($useCache = true)
    {
        $cacheKey = (string)($this);
        if ($useCache && isset(static::$pingCache[$cacheKey])) {
            return static::$pingCache[$cacheKey];
        }

        $pingQuery = $this->client->createPing();
        $pingResult = $this->createAndExecuteRequest($pingQuery);

        if ($useCache) {
            static::$pingCache[$cacheKey] = $pingResult;
        }

        return $pingResult;
    }
902223
protected function getResponse($requestUrl)
    {
        $response = $this->getHttpClient()->get($requestUrl);
        return json_decode($response->getBody()->getContents(), true);
    }
1123747
public function execute($uri, $requestMethod)
    {
        foreach ($this->routes as $route) {
            if (true === $route->matches($uri, $requestMethod)) {
                return $route;
            }
        }
        return null;
    }
922780
public function get($url = null, $requestBody = null)
    {
        if(!empty($requestBody))
        {
            if(strpos($url, '?'))
            {
                $url .= '&';
            }
            else
            {
                $url .= '?';
            }
            $url .= http_build_query($requestBody, '', '&');
        }
        return $this->send($url, array(), 'GET');
    }
634142
public boolean shouldCache(String requestUri) {
		String uri = requestUri.toLowerCase();
		return checkContains(uri, cacheIdentifiers) || checkSuffixes(uri, cacheSuffixes);
	}
76013
public function get($userId)
    {

        $param = array('userid'=>$userId);

        return new Bag($this->http->get(self::API_GET, $param));
    }
598395
public function _get($_name)
    {
        $getMethod = 'get' . ucfirst($_name);
        if(method_exists($this,$getMethod))
            return $this->$getMethod();
        else
            return false;
    }
1316547
public function write(SessionBagInterface $sessionBag)
    {
        if ($this->hasRequiredParams()) {

            // Writes hashes, not values themselves
            $sessionBag->set(self::PARAM_REMOTE_ADDR, $this->hash($this->getRemoteAddr()));
            $sessionBag->set(self::PARAM_USER_AGENT, $this->hash($this->getUserAgent()));
        }
    }
472474
function getSecretBag (req, sessionKey, cookie) {
  if (cookie) {
    // get secret from cookie
    var cookieKey = cookie.signed
      ? 'signedCookies'
      : 'cookies'

    return req[cookieKey]
  } else {
    // get secret from session
    return req[sessionKey]
  }
}
218520
private function isRequestCacheEnabled()
    {
        if (!$this->requestCache) {
            return false;
        }

        return $this->config->get('requestCache')->get('enabled') && $this->getCacheKey() !== null;
    }
1216801
protected function addToCache($requestUri)
    {
        // we found our match, stop looking for more and add to cache if cache is configured
        if ($this->cache instanceof Cache) {
            // prepare info to be saved to cache
            $toCache = [
                'matchedRoute' => $this->matchedRoute,
                'matchedEndpoint' => $this->matchedEndpoint,
                'params' => $this->params
            ];

            // check if we have any routes saved
            if ($cachedRoutes = $this->cache->get('routeMiddlewareRoutes')) {
                // add this route to cache
                $cachedRoutes[$requestUri] = $toCache;
            } else {
                // no routes found in cache, this is the first one we save
                $cachedRoutes = [
                    $requestUri => $toCache
                ];
            }
            // save to cache
            $this->cache->set('routeMiddlewareRoutes', $cachedRoutes);
        }
    }
1117386
public function get(CompilationContext $compilationContext, $method, $allowNtsCache = true)
    {
        if (!\is_object($method)) {
            return 'NULL, 0';
        }

        if (!($method instanceof \ReflectionMethod)) {
            $completeName = $method->getClassDefinition()->getCompleteName();

            /*
             * Avoid generate caches for external classes
             */
            if ($method->getClassDefinition()->isExternal()) {
                return 'NULL, 0';
            }

            if (isset($this->cache[$completeName][$method->getName()])) {
                return '&'.$this->cache[$completeName][$method->getName()]->getName().', '.SlotsCache::getExistingMethodSlot($method);
            }

            if ($method->getClassDefinition()->isInterface()) {
                return 'NULL, 0';
            }
        }

        $mustBeCached = false;
        if (!$compilationContext->insideCycle) {
            if (!($method instanceof \ReflectionMethod)) {
                $classDefinition = $method->getClassDefinition();
                if (!$classDefinition->isBundled() && $allowNtsCache) {
                    $mustBeCached = !$compilationContext->backend->isZE3();
                } else {
                    if (!$method->isPrivate() && !$method->isFinal()) {
                        return 'NULL, 0';
                    }
                }
            } else {
                if (!$method->isPrivate() && !$method->isFinal()) {
                    return 'NULL, 0';
                }
            }
        }

        $functionCache = $compilationContext->symbolTable->getTempVariableForWrite('zephir_fcall_cache_entry', $compilationContext);

        if ($method->isPrivate() || $method->isFinal() || $mustBeCached) {
            $cacheSlot = SlotsCache::getMethodSlot($method);
        } else {
            $cacheSlot = '0';
        }

        $functionCache->setMustInitNull(true);
        $functionCache->setReusable(false);

        if (!($method instanceof \ReflectionMethod)) {
            $this->cache[$completeName][$method->getName()] = $functionCache;
        }

        return '&'.$functionCache->getName().', '.$cacheSlot;
    }