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

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 3.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

That's a design issue: using root_dir as discriminant doesn't work with blue/green deployment strategies, and doesn't prevent collision when different apps are deployed in the same path while sharing the same cache backend.

@@ -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.

@fabpot
Copy link
Member

fabpot commented Nov 24, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 82952bd into symfony:3.2 Nov 24, 2016
fabpot added a commit that referenced this pull request Nov 24, 2016
…ictible cache key prefixes (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

That's a design issue: using root_dir as discriminant doesn't work with blue/green deployment strategies, and doesn't prevent collision when different apps are deployed in the same path while sharing the same cache backend.

Commits
-------

82952bd [FrameworkBundle] Add framework.cache.prefix_seed for predictible cache key prefixes
@nicolas-grekas nicolas-grekas deleted the cache-prefix branch November 24, 2016 09:34
nicolas-grekas added a commit that referenced this pull request Nov 25, 2016
…rating cache namespace (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

[Bridge/Doctrine] Use cache.prefix.seed parameter for generating cache namespace

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Exactly the same issue as in #20610, but for Doctrine ORM's cache:
> That's a design issue: using root_dir as discriminant doesn't work with blue/green deployment strategies, and doesn't prevent collision when different apps are deployed in the same path while sharing the same cache backend.

Commits
-------

5e3cbec [Bridge/Doctrine] Use cache.prefix.seed parameter for generating cache namespace
@fabpot fabpot mentioned this pull request Nov 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants