-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced separate cache type for navigation
- Loading branch information
Showing
21 changed files
with
243 additions
and
124 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
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
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
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
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
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
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
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,48 @@ | ||
<?php | ||
|
||
namespace MageSuite\Navigation\Model\Cache; | ||
|
||
class Type extends \Magento\Framework\Cache\Frontend\Decorator\TagScope | ||
{ | ||
const TYPE_IDENTIFIER = 'navigation'; | ||
const CACHE_TAG = 'navigation'; | ||
|
||
/** | ||
* @var \Magento\Framework\Event\Manager | ||
*/ | ||
protected $eventManager; | ||
|
||
/** | ||
* @var \Magento\Framework\Indexer\CacheContext | ||
*/ | ||
protected $cacheContext; | ||
|
||
/** | ||
* @param \Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool, | ||
\Magento\Framework\Event\Manager $eventManager, | ||
\Magento\Framework\Indexer\CacheContext $cacheContext | ||
) | ||
{ | ||
parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG); | ||
$this->eventManager = $eventManager; | ||
$this->cacheContext = $cacheContext; | ||
} | ||
|
||
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = []) | ||
{ | ||
if($mode == \Zend_Cache::CLEANING_MODE_ALL) { | ||
$this->clearFullPageCache(); | ||
} | ||
|
||
return parent::clean($mode, $tags); | ||
} | ||
|
||
public function clearFullPageCache(): void | ||
{ | ||
$this->cacheContext->registerTags([self::CACHE_TAG]); | ||
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]); | ||
} | ||
} |
Oops, something went wrong.