resolve() публичный Метод

Get cache lifetime in seconds.
public resolve ( string $type, mixed $value ) : integer
$type string
$value mixed
Результат integer Cache lifetime in seconds
Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function updateResponse(Response $response, StructureInterface $structure)
 {
     $response->headers->set(self::HEADER_HANDLERS, implode(', ', $this->handlerNames));
     $response->headers->set(self::HEADER_CLIENT_NAME, $this->proxyClientName);
     $response->headers->set(self::HEADER_STRUCTURE_TYPE, get_class($structure));
     $response->headers->set(self::HEADER_STRUCTURE_UUID, $structure->getUuid());
     // Structures implementing PageInterface have a TTL
     if ($structure instanceof PageInterface) {
         $cacheLifetimeData = $structure->getCacheLifeTime();
         $cacheLifeTime = $this->cacheLifetimeResolver->resolve($cacheLifetimeData['type'], $cacheLifetimeData['value']);
         $response->headers->set(self::HEADER_STRUCTURE_TTL, $cacheLifeTime);
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function updateResponse(Response $response, StructureInterface $structure)
 {
     if (!$structure instanceof PageInterface) {
         return;
     }
     $cacheLifetimeData = $structure->getCacheLifeTime();
     $cacheLifetime = $this->cacheLifetimeResolver->resolve($cacheLifetimeData['type'], $cacheLifetimeData['value']);
     // when structure cache-lifetime disabled - return
     if (0 === $cacheLifetime) {
         return;
     }
     // mark the response as either public or private
     $response->setPublic();
     // set the private and shared max age
     $response->setMaxAge($this->maxAge);
     $response->setSharedMaxAge($this->sharedMaxAge);
     $proxyTtl = $this->usePageTtl ? $response->getAge() + $cacheLifetime : $response->getAge();
     // set reverse-proxy TTL (Symfony HttpCache, Varnish, ...)
     $response->headers->set(HttpCache::HEADER_REVERSE_PROXY_TTL, $proxyTtl);
 }