CleanCache.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Cron;
  7. /**
  8. * Backend event observer
  9. */
  10. class CleanCache
  11. {
  12. /**
  13. * @var \Magento\Framework\App\Cache\Frontend\Pool
  14. */
  15. private $cacheFrontendPool;
  16. /**
  17. * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
  18. */
  19. public function __construct(
  20. \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
  21. ) {
  22. $this->cacheFrontendPool = $cacheFrontendPool;
  23. }
  24. /**
  25. * Cron job method to clean old cache resources
  26. *
  27. * @return void
  28. */
  29. public function execute()
  30. {
  31. /** @var $cacheFrontend \Magento\Framework\Cache\FrontendInterface */
  32. foreach ($this->cacheFrontendPool as $cacheFrontend) {
  33. // Magento cache frontend does not support the 'old' cleaning mode, that's why backend is used directly
  34. $cacheFrontend->getBackend()->clean(\Zend_Cache::CLEANING_MODE_OLD);
  35. }
  36. }
  37. }