开发者

How to Clear Magento's Caching of its DB Schema?

I'm developing a Magento extension that introduces a new table to the DB. Whenever I release a new version of the extension that makes modifications to the table schema, I find that users are forced to manually click the "Flush Cache Storage" button under System > Cache Management.

I'd like to have my extension automatically clear the cache upon being installed. I know how to do the same thing as the button programmatically but I'd prefer not to, because this deletes the entire Magento cache folder and impacts negatively on performance.

Might anyone know how to write code that w开发者_StackOverflow社区ill clear the caching of my table's schema and do so as specifically as possible - leaving unrelated cached data unharmed?

Update: I've found the file containing my table's schema cache here: /var/cache/mage-f/mage---d07_DB_PDO_MYSQL_DDL_<table_name>_1d . Now how do I target it in code? :)


This is what I've been able to come up with:

$app = Mage::app();
if ($app != null)
{
    $cache = $app->getCache();
    if ($cache != null)
    {
        $cache->clean('matchingTag', array('DB_PDO_MYSQL_DDL'));
    }
}

This will delete only the cache entries and metadata files that hold information about DB schemas.

Note that it will delete these entries for all tables. There's no simple way to clear a specific table's cached schema and leave the rest untouched.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜