Пример #1
0
 /**
  *  @test
  */
 public function it_doesnt_parse_error_responses()
 {
     $response = new Response();
     $response->setContent('Content');
     $response->setStatusCode(500);
     $response->headers = new ResponseHeaderBag(['header' => 'value']);
     $responseParser = new ResponseParser($response);
     $this->assertFalse($responseParser->isCacheable());
     $this->assertNull($responseParser->cacheValue());
 }
Пример #2
0
 /**
  *  Store the response for a given request in the cache
  *
  *  @param  Request     $request
  *  @param  Response    $response
  *  @param  integer     $minutes
  *  @return void
  */
 public function put(Request $request, Response $response, $minutes)
 {
     if (!$this->allowQueries) {
         return;
     }
     $parsedRequest = new RequestParser($request);
     $cacheKey = $parsedRequest->cacheKey();
     // If the request is not cacheable, return
     if (!$cacheKey) {
         return;
     }
     $parsedResponse = new ResponseParser($response);
     $cacheValue = $parsedResponse->cacheValue($this->headerName);
     // If the response is not cacheable, return
     if (!$cacheValue) {
         return;
     }
     $this->repository->put($cacheKey, $cacheValue, $minutes);
 }