Skip to content

[FrameworkBundle] Add framework.cache.prefix_seed for predictible cache key prefixes #20610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public function process(ContainerBuilder $container)
{
$namespaceSuffix = '';

foreach (array('name', 'root_dir', 'environment', 'debug') as $key) {
if ($container->hasParameter('kernel.'.$key)) {
$namespaceSuffix .= '.'.$container->getParameter('kernel.'.$key);
foreach (array('kernel.name', 'kernel.environment', 'kernel.debug', 'cache.prefix.seed') as $key) {
if ($container->hasParameter($key)) {
$namespaceSuffix .= '.'.$container->getParameter($key);
}
}
$container->getParameterBag()->remove('cache.prefix.seed');

$aliases = $container->getAliases();
$attributes = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,10 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
->addDefaultsIfNotSet()
->fixXmlConfig('pool')
->children()
->scalarNode('prefix_seed')
->info('Used to namespace cache keys when using several apps with the same shared backend')
->example('my-application-name')
->end()
->scalarNode('app')
->info('App related cache pools configuration')
->defaultValue('cache.adapter.filesystem')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,9 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);

if (isset($config['prefix_seed'])) {
$container->setParameter('cache.prefix.seed', $config['prefix_seed']);
Copy link
Contributor

@ro0NL ro0NL Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not setting it directly on the pass it self? Yes; foreaching all passes to find any instance of CachePoolPass.

Otherwise maybe use a less generic name, to clarify something's going on (it's a tmp thingy, only to transfer config..), ie. setParameter(CachePoolPass::class.'_prefix_seed').

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To achieve which goal?

Copy link
Contributor

@ro0NL ro0NL Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess to avoid creating params into the wild and making things less implicit. Im fine with it though.. just curious :)

This mix&matches framework.cache.prefix_seed and %cache.prefix.seed%, they're the same. In apps this often shows a code smell, as people tend to use params as some global config array, by exactly doing this.

}
foreach (array('doctrine', 'psr6', 'redis') as $name) {
if (isset($config[$name = 'default_'.$name.'_provider'])) {
$container->setAlias('cache.'.$name, Compiler\CachePoolPass::getServiceProvider($container, $config[$name]));
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy