Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cache.php
Go to the documentation of this file.
1 <?php
11 namespace Magento\Framework\App;
12 
13 class Cache implements CacheInterface
14 {
19 
23  protected $_frontendPool;
24 
30  protected $_frontend;
31 
35  public function __construct(\Magento\Framework\App\Cache\Frontend\Pool $frontendPool)
36  {
37  $this->_frontendPool = $frontendPool;
38  $this->_frontend = $frontendPool->get($this->_frontendIdentifier);
39  }
40 
46  public function getFrontend()
47  {
48  return $this->_frontend;
49  }
50 
57  public function load($identifier)
58  {
59  return $this->_frontend->load($identifier);
60  }
61 
71  public function save($data, $identifier, $tags = [], $lifeTime = null)
72  {
73  return $this->_frontend->save((string)$data, $identifier, $tags, $lifeTime);
74  }
75 
82  public function remove($identifier)
83  {
84  return $this->_frontend->remove($identifier);
85  }
86 
93  public function clean($tags = [])
94  {
95  if ($tags) {
96  $result = $this->_frontend->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, (array)$tags);
97  } else {
99  $result = false;
101  foreach ($this->_frontendPool as $cacheFrontend) {
102  if ($cacheFrontend->clean()) {
103  $result = true;
104  }
105  }
106  }
107  return $result;
108  }
109 }
__construct(\Magento\Framework\App\Cache\Frontend\Pool $frontendPool)
Definition: Cache.php:35
const CLEANING_MODE_MATCHING_ANY_TAG
Definition: Cache.php:76
save($data, $identifier, $tags=[], $lifeTime=null)
Definition: Cache.php:71