Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigCache.php
Go to the documentation of this file.
1 <?php
9 
12 
14 {
18  protected $_cacheFrontend;
19 
25  protected $_prefix = 'diConfig';
26 
30  private $serializer;
31 
35  public function __construct(\Magento\Framework\Cache\FrontendInterface $cacheFrontend)
36  {
37  $this->_cacheFrontend = $cacheFrontend;
38  }
39 
46  public function get($key)
47  {
48  $data = $this->_cacheFrontend->load($this->_prefix . $key);
49  if (!$data) {
50  return false;
51  }
52  return $this->getSerializer()->unserialize($data);
53  }
54 
62  public function save(array $config, $key)
63  {
64  $this->_cacheFrontend->save($this->getSerializer()->serialize($config), $this->_prefix . $key);
65  }
66 
73  private function getSerializer()
74  {
75  if (null === $this->serializer) {
76  $this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(Serialize::class);
77  }
78  return $this->serializer;
79  }
80 }
$config
Definition: fraud_order.php:17
__construct(\Magento\Framework\Cache\FrontendInterface $cacheFrontend)
Definition: ConfigCache.php:35