Skip to content

Commit cd1694e

Browse files
Tobionnicolas-grekas
authored andcommitted
[Cache] give control over cache prefix seed
The configurable cache prefix seed does not give full control over the cache prefix because the container class is added to the prefix in any case. This is a problem because the container class contains the app env name. We use different app environments for different deployment targets (dev and test). Dev and test should use the same redis cache. But this is impossible to achieve because even setting the cache prefix seed does not accomplish this.
1 parent 8411b83 commit cd1694e

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,8 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
982982
->children()
983983
->scalarNode('prefix_seed')
984984
->info('Used to namespace cache keys when using several apps with the same shared backend')
985-
->example('my-application-name')
985+
->defaultValue('_%kernel.project_dir%.%kernel.container_class%')
986+
->example('my-application-name/%kernel.environment%')
986987
->end()
987988
->scalarNode('app')
988989
->info('App related cache pools configuration')

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ protected static function getBundleDefaultConfig()
463463
'default_redis_provider' => 'redis://localhost',
464464
'default_memcached_provider' => 'memcached://localhost',
465465
'default_pdo_provider' => class_exists(Connection::class) ? 'database_connection' : null,
466+
'prefix_seed' => '_%kernel.project_dir%.%kernel.container_class%',
466467
],
467468
'workflows' => [
468469
'enabled' => false,

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,11 +1334,11 @@ public function testCachePoolServices()
13341334
(new ChildDefinition('cache.adapter.array'))
13351335
->replaceArgument(0, 12),
13361336
(new ChildDefinition('cache.adapter.filesystem'))
1337-
->replaceArgument(0, 'xctxZ1lyiH')
1337+
->replaceArgument(0, 'UKoP1K+Hox')
13381338
->replaceArgument(1, 12),
13391339
(new ChildDefinition('cache.adapter.redis'))
13401340
->replaceArgument(0, new Reference('.cache_connection.kYdiLgf'))
1341-
->replaceArgument(1, 'xctxZ1lyiH')
1341+
->replaceArgument(1, 'UKoP1K+Hox')
13421342
->replaceArgument(2, 12),
13431343
],
13441344
12,

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=7.2.5",
2020
"ext-xml": "*",
21-
"symfony/cache": "^4.4|^5.0",
21+
"symfony/cache": "^5.2",
2222
"symfony/config": "^5.0",
2323
"symfony/dependency-injection": "^5.2",
2424
"symfony/event-dispatcher": "^5.1",

0 commit comments

Comments
 (0)