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
8 
13 class Cache implements CacheInterface
14 {
18  const ACL_DATA_CACHE_TAG = 'acl_cache';
19 
23  private $cache;
24 
28  private $aclBuilder;
29 
33  private $cacheTag;
34 
42  public function __construct(
43  \Magento\Framework\Config\CacheInterface $cache,
44  \Magento\Framework\Acl\Builder $aclBuilder,
45  $cacheTag = self::ACL_DATA_CACHE_TAG
46  ) {
47  $this->cache = $cache;
48  $this->aclBuilder = $aclBuilder;
49  $this->cacheTag = $cacheTag;
50  }
51 
55  public function test($identifier)
56  {
57  return $this->cache->test($identifier);
58  }
59 
63  public function load($identifier)
64  {
65  return $this->cache->load($identifier);
66  }
67 
71  public function save($data, $identifier, array $tags = [], $lifeTime = null)
72  {
73  return $this->cache->save($data, $identifier, array_merge($tags, [$this->cacheTag]), $lifeTime);
74  }
75 
79  public function remove($identifier)
80  {
81  return $this->cache->remove($identifier);
82  }
83 
87  public function clean($mode = \Zend_Cache::CLEANING_MODE_MATCHING_TAG, array $tags = [])
88  {
89  $this->aclBuilder->resetRuntimeAcl();
90  return $this->cache->clean($mode, array_merge($tags, [$this->cacheTag]));
91  }
92 
96  public function getBackend()
97  {
98  return $this->cache->getBackend();
99  }
100 
104  public function getLowLevelFrontend()
105  {
106  return $this->cache->getLowLevelFrontend();
107  }
108 }
save($data, $identifier, array $tags=[], $lifeTime=null)
Definition: Cache.php:71
__construct(\Magento\Framework\Config\CacheInterface $cache, \Magento\Framework\Acl\Builder $aclBuilder, $cacheTag=self::ACL_DATA_CACHE_TAG)
Definition: Cache.php:42
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
const CLEANING_MODE_MATCHING_TAG
Definition: Cache.php:74
clean($mode=\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array $tags=[])
Definition: Cache.php:87