Skip to content

Commit

Permalink
Merge branch '7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Oct 4, 2018
2 parents ba0bf59 + 2a8ce8a commit 70e23f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions eZ/Bundle/EzPublishCoreBundle/ApiLoader/CacheFactory.php
Expand Up @@ -10,6 +10,7 @@

use eZ\Publish\Core\MVC\ConfigResolverInterface;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

Expand All @@ -25,12 +26,20 @@ class CacheFactory implements ContainerAwareInterface
/**
* @param ConfigResolverInterface $configResolver
*
* @return \Symfony\Component\Cache\Adapter\TagAwareAdapter
* @return \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface
*/
public function getCachePool(ConfigResolverInterface $configResolver)
{
/** @var \Symfony\Component\Cache\Adapter\AdapterInterface $cacheService */
$cacheService = $this->container->get($configResolver->getParameter('cache_service_name'));

// If cache service is already implementing TagAwareAdapterInterface, return as-is
if ($cacheService instanceof TagAwareAdapterInterface) {
return $cacheService;
}

return new TagAwareAdapter(
$this->container->get($configResolver->getParameter('cache_service_name'))
$cacheService
);
}
}
3 changes: 2 additions & 1 deletion eZ/Publish/Core/settings/containerBuilder.php
Expand Up @@ -13,6 +13,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Config\FileLocator;
use eZ\Publish\Core\Base\Container\Compiler;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Config\Resource\FileResource;

if (!isset($installDir)) {
Expand Down Expand Up @@ -62,7 +63,7 @@
->addMethodCall('connect', [(getenv('CACHE_HOST') ?: '127.0.0.1'), 6379, 2.5]);

$containerBuilder
->register('ezpublish.cache_pool.driver', 'Symfony\Component\Cache\Adapter\RedisAdapter')
->register('ezpublish.cache_pool.driver', RedisAdapter::class)
->setArguments([new Reference('ezpublish.cache_pool.driver.redis'), '', 120]);
}

Expand Down

0 comments on commit 70e23f5

Please sign in to comment.