Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cache seeds change when pool configuration is changed #33561

Copy link
Copy link
Closed
@roed

Description

@roed
Issue body actions

Symfony version(s) affected: 4.3.*

Description
We noticed that in symfony/cache a change is introduced for the seed/namespace in cache pools. This was done in symfony/cache@d8dda03
In that commit, the seed is suffixed with the class of the adapter. However, this is done in a for loop, so if a certain pool is added in the configuration before the previously defined pool, the original pool seed also changes. This is because the code now does something like: $seed .= '.'.$class;. Every next pool will receive the classes of the previous pools, plus the adapter pool of the current one. This seems like a side effect that is not desirable. It seems something like this should fix that issue:

$namespaceSeed = $seed;
if (null !== $class) {
    $namespaceSeed .= '.'.$class;
}

$tags[0]['namespace'] = $this->getNamespace($namespaceSeed, $name);

That way, the seeds won't change if pools are added/removed. In our case we are leaning heavy on cache, so if adding an extra pool could cause major issues on deploys.

How to reproduce
Define a pool, eg:

framework:
    cache:
        app: cache.adapter.redis
        default_redis_provider: "xxxxx"
        prefix_seed: "some-seed"
        pools:
            cache.some_pool:
                adapter: cache.adapter.redis
                tags: true

Place a var dump in \Symfony\Component\Cache\DependencyInjection\CachePoolPass::process after $tags[0]['namespace'], eg: var_dump($id, $tags[0]['namespace'])

Run bin/console cache:clear, this will trigger \Symfony\Component\Cache\DependencyInjection\CachePoolPass::process.

Copy the namespace for the pool cache.some_pool

Add an extra pool above cache.some_pool in the configuration and run the bin/console cache:clear again. See that the namespace for the original cache.some_pool is also changed.

Possible Solution
See the possible solution at the top of this issue.

Additional context
na

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.