cancel
Showing results for 
Search instead for 
Did you mean: 

seems that if cache_lifetime not set , the block will never been cached

seems that if cache_lifetime not set , the block will never been cached

protected function _saveCache($data)
    {
        if (!$this->getCacheLifetime() || !$this->_cacheState->isEnabled(self::CACHE_GROUP)) {
            return false;
        }
        $cacheKey = $this->getCacheKey();
        $data = str_replace(
            $this->_sidResolver->getSessionIdQueryParam($this->_session) . '=' . $this->_session->getSessionId(),
            $this->_getSidPlaceholder($cacheKey),
            $data
        );

        $this->_cache->save($data, $cacheKey, array_unique($this->getCacheTags()), $this->getCacheLifetime());
        return $this;
    }

 
protected function getCacheLifetime()
{
if (!$this->hasData('cache_lifetime')) {
return null;
}

$cacheLifetime = $this->getData('cache_lifetime');
if (false === $cacheLifetime || null === $cacheLifetime) {
return $cacheLifetime;
}

return (int)$cacheLifetime;


}


 !$this->getCacheLifetime() will always set to be true if the block does not have cache_lifetime attribute ?

Can anyone help me ?