10000 [FrameworkBundle] alias `cache.app.taggable` to `cache.app` if using `cache.adapter.redis_tag_aware` by kbond · Pull Request #44673 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] alias cache.app.taggable to cache.app if using cache.adapter.redis_tag_aware #44673

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
---

* Environment variable `SYMFONY_IDE` is read by default when `framework.ide` config is not set.
* When `cache.app` is `cache.adapter.redis_tag_aware`, set `cache.app.taggable` as an alias.

6.0
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,15 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
'tags' => false,
];
}

if ('cache.adapter.redis_tag_aware' === $config['app']) {
Copy link
Member

Choose a reason for hiding this comment

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

In theory, any pool can inherit from redis_tag_aware and require making cache.app an alias

Copy link
Member Author
@kbond kbond Dec 16, 2021

Choose a reason for hiding this comment

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

If I understand you correctly, the same could be said for the non-app cache pools below, correct? (cache.adapter.redis_tag_aware is hard-coded)

Copy link
Member

Choose a reason for hiding this comment

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

absolutely, recursively also, since pools can derivate from other pools.

Copy link
Member Author
@kbond kbond Dec 16, 2021

Choose a reason for hiding this comment

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

Ultimately, I don't think there shouldn't be any redis-specific check here at all. As discussed in slack, we should be using a pass to determine if the adapter used is already tag aware and alias/decorate based on that.

What do you think about matching what we do for custom pools now for 5.3 as a bug fix, then adding a more robust system in 6.1?

Copy link
Member

Choose a reason for hiding this comment

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

but the alias is created in the DI extension - the pass doesn't know about them

Copy link
Member Author

Choose a reason for hiding this comment

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

Think I finally understand and I believe #44682 solves.

$container->setAlias('cache.app.taggable', 'cache.app');
} else {
$container->register('cache.app.taggable', TagAwareAdapter::class)
->addArgument(new Reference('cache.app'))
;
}

foreach ($config['pools'] as $name => $pool) {
$pool['adapters'] = $pool['adapters'] ?: ['cache.app'];

Expand Down
4 changes: 0 additions & 4 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Symfony\Component\Cache\Adapter\ProxyAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
use Symfony\Component\Cache\Messenger\EarlyExpirationHandler;
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
Expand All @@ -37,9 +36,6 @@
->public()
->tag('cache.pool', ['clearer' => 'cache.app_clearer'])

->set('cache.app.taggable', TagAwareAdapter::class)
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer keeping this definition as is

Copy link
Member Author

Choose a reason for hiding this comment

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

And just change to an alias if applicable in the extension?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

->args([service('cache.app')])

->set('cache.system')
->parent('cache.adapter.system')
->public()
Expand Down
0