I need to do a overwrite of \Magento\Framework\App\ObjectManager\ConfigCache
preference on di.xml do no work, also tray to create a plugin for save but did not work
how can i do a overwrite of this calss?
i am on magento 2.2.6 and php 7.1.26
what i looking for is change the cache key some thing like this
<?php
/**
* Object manager configuration cache
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Serialize\Serializer\Serialize;
class ConfigCache implements \Magento\Framework\ObjectManager\ConfigCacheInterface
{
/**
* @var \Magento\Framework\Cache\FrontendInterface
*/
protected $_cacheFrontend;
/**
* Cache prefix
*
* @var string
*/
protected $_prefix = 'diConfig';
/**
* @var SerializerInterface
*/
private $serializer;
/**
* @var \Magento\Framework\Url\ScopeInterface
*/
private $scope;
/**
* @param \Magento\Framework\Cache\FrontendInterface $cacheFrontend
* @param \Magento\Framework\Url\ScopeResolverInterface $scopeResolver
*/
public function __construct(
\Magento\Framework\Cache\FrontendInterface $cacheFrontend,
\Magento\Framework\Url\ScopeResolverInterface $scopeResolver
)
{
$this->_cacheFrontend = $cacheFrontend;
try {
$this->scope = $scopeResolver->getScope();
} catch (\Exception $e) {
$this->scope= null;
}
}
public function updateKey($key)
{
if ($this->scope == null ) {
$key = implode('-', [$this->_prefix, $key]);
} else {
$key = implode('-', [$this->_prefix, $this->scope->getId(), $key]);
}
return $key;
}
/**
* Retrieve configuration from cache
*
* @param string $key
* @return array|false
*/
public function get($key)
{
$key = $this->updateKey($key);
$data = $this->_cacheFrontend->load($key);
if (!$data) {
return false;
}
return $this->getSerializer()->unserialize($data);
}
/**
* Save config to cache
*
* @param array $config
* @param string $key
* @return void
*/
public function save(array $config, $key)
{
$key = $this->updateKey($key);
$this->_cacheFrontend->save($this->getSerializer()->serialize($config), $key);
}
/**
* Get serializer
*
* @return SerializerInterface
* @deprecated 100.2.0
*/
private function getSerializer()
{
if (null === $this->serializer) {
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(Serialize::class);
}
return $this->serializer;
}
}