Kevinrob\GuzzleCache\Strategy\GreedyCacheStrategy::cache PHP Method

cache() public method

public cache ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response )
$request Psr\Http\Message\RequestInterface
$response Psr\Http\Message\ResponseInterface
    public function cache(RequestInterface $request, ResponseInterface $response)
    {
        $warningMessage = sprintf('%d - "%s" "%s"', 299, 'Cached although the response headers indicate not to do it!', (new \DateTime())->format(\DateTime::RFC1123));
        $response = $response->withAddedHeader('Warning', $warningMessage);
        if ($cacheObject = $this->getCacheObject($request, $response)) {
            return $this->storage->save($this->getCacheKey($request), $cacheObject);
        }
        return false;
    }