Skip to content

Commit 82665c4

Browse files
committed
feature #18716 [Cache] Add nonce based cache invalidation to ApcuAdapter (nicolas-grekas)
This PR was merged into the 3.1-dev branch. Discussion ---------- [Cache] Add nonce based cache invalidation to ApcuAdapter | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - APCu cache invalidation is tedious because it can't be done from the cli. This PR adds and wires a nonce based cache invalidation strategy to work around this limitation. Commits ------- a7899fe [Cache] Add nonce based cache invalidation to ApcuAdapter
2 parents df51925 + 4a0b51b commit 82665c4

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,8 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
10371037

10381038
private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
10391039
{
1040+
$nonce = substr(str_replace('/', '-', base64_encode(md5(uniqid(mt_rand(), true), true))), 0, -2);
1041+
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $nonce);
10401042
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
10411043

10421044
foreach (array('doctrine', 'psr6', 'redis') as $name) {

Resources/config/cache.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<tag name="monolog.logger" channel="cache" />
2828
<argument /> <!-- namespace -->
2929
<argument /> <!-- default lifetime -->
30+
<argument /> <!-- nonce -->
3031
<call method="setLogger">
3132
<argument type="service" id="logger" on-invalid="ignore" />
3233
</call>

0 commit comments

Comments
 (0)