Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7177a42

Browse filesBrowse files
committed
Added keep-in-memory option for cache adapters
1 parent 47e571b commit 7177a42
Copy full SHA for 7177a42

File tree

3 files changed

+27
-0
lines changed
Filter options

3 files changed

+27
-0
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
995995
->info('Overwrite the setting from the default provider for this adapter.')
996996
->end()
997997
->scalarNode('clearer')->end()
998+
->booleanNode('keep_in_memory')->defaultFalse()->end()
998999
->end()
9991000
->end()
10001001
->validate()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\Cache\Adapter\AbstractAdapter;
2929
use Symfony\Component\Cache\Adapter\AdapterInterface;
3030
use Symfony\Component\Cache\Adapter\ArrayAdapter;
31+
use Symfony\Component\Cache\Adapter\ChainAdapter;
3132
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
3233
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
3334
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
@@ -1797,6 +1798,17 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
17971798
$name = '.'.$name.'.inner';
17981799
}
17991800
$definition->setPublic($pool['public']);
1801+
1802+
if ($config['pools'][$name]['keep_in_memory'] ?? false) {
1803+
$container->register($name.'.keep_in_memory', ChainAdapter::class)
1804+
->setDecoratedService($name)
1805+
->addArgument([
1806+
new Definition(ArrayAdapter::class),
1807+
new Reference($name.'.keep_in_memory.inner'),
1808+
])
1809+
->setPublic(true);
1810+
}
1811+
18001812
unset($pool['adapter'], $pool['public'], $pool['tags']);
18011813

18021814
$definition->addTag('cache.pool', $pool);

‎src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1515
use Symfony\Component\Cache\Adapter\ArrayAdapter;
16+
use Symfony\Component\Cache\Adapter\ChainAdapter;
1617
use Symfony\Component\DependencyInjection\ChildDefinition;
1718
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -104,6 +105,19 @@ public function process(ContainerBuilder $container)
104105
}
105106
unset($tags[0][$attr]);
106107
}
108+
109+
if ($tags[0]['keep_in_memory'] ?? false) {
110+
$container->register($id.'.keep_in_memory', ChainAdapter::class)
111+
->setDecoratedService($id)
112+
->addArgument([
113+
new Definition(ArrayAdapter::class),
114+
new Reference($id.'.keep_in_memory.inner'),
115+
])
116+
->setPublic(true);
117+
}
118+
119+
unset($tags[0]['keep_in_memory']);
120+
107121
if (!empty($tags[0])) {
108122
throw new InvalidArgumentException(sprintf('Invalid "%s" tag for service "%s": accepted attributes are "clearer", "provider", "name", "namespace", "default_lifetime" and "reset", found "%s".', $this->cachePoolTag, $id, implode('", "', array_keys($tags[0]))));
109123
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.