-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the process of clearing the cache.
Each cache type can consist of one or more cache tags. This patch uses the cache tags that have been configured in magento for each cache segment instead of using a single hardcoded 'config' tag. This touches on issue #19, but doesn't resolve it completely yet.
- Loading branch information
Showing
3 changed files
with
123 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* BehatMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the MIT License, that is bundled with this | ||
* package in the file LICENSE. | ||
* It is also available through the world-wide-web at this URL: | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
* If you did not receive a copy of the license and are unable to obtain it | ||
* through the world-wide-web, please send an email | ||
* to <[email protected]> so we can send you a copy immediately. | ||
* | ||
* @category MageTest | ||
* @package MagentoExtension | ||
* @subpackage Service\Cache | ||
* | ||
* @copyright Copyright (c) 2012-2013 MageTest team and contributors. | ||
*/ | ||
namespace MageTest\MagentoExtension\Service\Cache; | ||
|
||
use Mage_Core_Model_App; | ||
|
||
/** | ||
* ConfigurationCache | ||
* | ||
* @category MageTest | ||
* @package MagentoExtension | ||
* @subpackage Service\Cache | ||
* | ||
* @author MageTest team (https://github.com/MageTest/BehatMage/contributors) | ||
*/ | ||
abstract class BaseCache | ||
{ | ||
/** | ||
* List of cache types to clear. | ||
* | ||
* For example: | ||
* - config | ||
* - block_html | ||
* - layout | ||
* - translate | ||
* | ||
* @var array | ||
*/ | ||
protected $cacheTypes = array(); | ||
|
||
/** | ||
* Internal instance of MageApp | ||
* | ||
* @var Mage_Core_Model_App | ||
**/ | ||
protected $mageApp; | ||
|
||
|
||
public function __construct(Mage_Core_Model_App $mageApp) | ||
{ | ||
$this->mageApp = $mageApp; | ||
} | ||
|
||
public function clear() | ||
{ | ||
$this->mageApp->cleanCache($this->getCacheTags()); | ||
} | ||
|
||
/** | ||
* All listed types must be declared under global/cache/types | ||
* | ||
* @return array | ||
*/ | ||
private function getCacheTags() | ||
{ | ||
$tags = array(); | ||
foreach ($this->cacheTypes as $type) { | ||
$tags = array_merge($tags, $this->mageApp->getCacheInstance()->getTagsByType($type)); | ||
} | ||
return $tags; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/MageTest/MagentoExtension/Service/Cache/BlockHtmlCache.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* BehatMage | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the MIT License, that is bundled with this | ||
* package in the file LICENSE. | ||
* It is also available through the world-wide-web at this URL: | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
* If you did not receive a copy of the license and are unable to obtain it | ||
* through the world-wide-web, please send an email | ||
* to <[email protected]> so we can send you a copy immediately. | ||
* | ||
* @category MageTest | ||
* @package MagentoExtension | ||
* @subpackage Service\Cache | ||
* | ||
* @copyright Copyright (c) 2012-2013 MageTest team and contributors. | ||
*/ | ||
namespace MageTest\MagentoExtension\Service\Cache; | ||
|
||
use Mage_Core_Model_App; | ||
|
||
/** | ||
* ConfigurationCache | ||
* | ||
* @category MageTest | ||
* @package MagentoExtension | ||
* @subpackage Service\Cache | ||
* | ||
* @author MageTest team (https://github.com/MageTest/BehatMage/contributors) | ||
*/ | ||
class ConfigurationCache extends BaseCache | ||
{ | ||
protected $cacheTypes = array('block_html'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters