davidselo
davidselo

Reputation: 1325

Magento: How to know many blocks are cached

i cached my custom block inherit of Mage_Core_Block_Template. I cached the bloc with the next constructor:

protected function _construct()
    {
        $this->addData(array(
        'cache_lifetime'    => 120,
        'cache_tags'        => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG),
                ));
    }

Right, i want verify that this block is cached. How i can list all block cached in my Magento. I want a similar instruction:

var_dump($this->getLayout()->getUpdate()->getHandles());exit; 

to see all layout , in blocks cached. thx.

Upvotes: 2

Views: 2884

Answers (2)

Victor Priceputu
Victor Priceputu

Reputation: 666

To see if Magento created your cache, you could search for the file that contains in it's name your tags in the var folder. Also make sure you have your cache activated for this to work.

Upvotes: 0

Roman Snitko
Roman Snitko

Reputation: 3655

You can specify cache_key for your block:

protected function _construct()
{
    $this->addData(array(
        'cache_key' => 'some_static_or_dynamic_key', // can be static or dynamic
        'cache_lifetime'    => 120,
        'cache_tags'        => array(
            Mage_Core_Model_Store::CACHE_TAG,
            Mage_Cms_Model_Block::CACHE_TAG),
        )
    );
}

And then you can ensure that block is cached by calling:

Mage::app()->loadCache('your_cache_key');

Here is good article about blocks caching.

Upvotes: 4

Related Questions