private function randomizeExpirationTime(CacheItemInterface $item)
    {
        // Get expires time (if previously set by headers forwarding)
        $expiresAtTimestamp = $item->getExpiresAt() ? $item->getExpiresAt()->getTimestamp() : null;

        // Generate expires time from creation date and default interval
        $expiresAtTimestamp = $expiresAtTimestamp ?: ($item->getCreatedAt()->getTimestamp() + $this->cacheExpiresIn);

        // Slightly random offset
        $offset = log10(mt_rand(10, 1000)) * mt_rand(-2, 2);
        $item->setExpiresAt((new DateTime())->setTimestamp($expiresAtTimestamp + $offset));
    }
private function randomizeExpirationTime(CacheItemInterface $item)
    {
        // Get expires time (if previously set by headers forwarding)
        $expiresAtTimestamp = $item->getExpiresAt() ? $item->getExpiresAt()->getTimestamp() : null;

        // Generate expires time from creation date and default interval
        $expiresAtTimestamp = $expiresAtTimestamp ?: ($item->getCreatedAt()->getTimestamp() + $this->cacheExpiresIn);

        // Slightly random offset
        $offset = log10(mt_rand(10, 1000)) * mt_rand(-2, 2);
        $item->setExpiresAt((new DateTime())->setTimestamp($expiresAtTimestamp + $offset));
    }
private function randomizeExpirationTime ( CacheItemInterface $ item ) { // Get expires time (if previously set by headers forwarding) $ expiresAtTimestamp = $ item -> getExpiresAt ( ) ? $ item -> getExpiresAt ( ) -> getTimestamp ( ) : null ; // Generate expires time from creation date and default interval $ expiresAtTimestamp = $ expiresAtTimestamp ? : ( $ item -> getCreatedAt ( ) -> getTimestamp ( ) + $ this -> cacheExpiresIn ) ; // Slightly random offset $ offset = log10 ( mt_rand ( 10 , 1000 ) ) * mt_rand ( - 2 , 2 ) ; $ item -> setExpiresAt ( ( new DateTime ( ) ) -> setTimestamp ( $ expiresAtTimestamp + $ offset ) ) ; }
Calculate and returns item's expiration time.

Cache expiration is cacheExpire seconds +/- a random value of seconds, from -6 to 6.

So although expiration is set for example 200 seconds, it is not guaranteed that it will expire in exactly
that many seconds. It could expire at 200 seconds, but also could expire in 206 seconds, or 194 seconds, or
anywhere in between 206 and 194 seconds. This is done to better deal with cache stampede, and improve cache
hit rate.

@param \PageCache\Storage\CacheItemInterface $item
Calculate and returns item s expiration time .