Skip to content

Symfony doesn't remove cache by tags #27273

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
byvlad opened this issue May 15, 2018 · 4 comments
Closed

Symfony doesn't remove cache by tags #27273

byvlad opened this issue May 15, 2018 · 4 comments

Comments

@byvlad
Copy link

byvlad commented May 15, 2018

Symfony version: 3.4.9

Reproducing:

$cache = new TagAwareAdapter($this->get('cache.app'));
$pagination = $cache->getItem(PostTypeDictionary::CACHE_MEDIA_PREFIX . $postType . $request->get('page', 1));

if (!$pagination->isHit()) {
    $data = getSomeData();

    $pagination->tag(
        [
            PostTypeDictionary::CACHE_MEDIA_PREFIX,
            PostTypeDictionary::CACHE_MEDIA_PREFIX . $postType,
        ]
    );
    $pagination->set($data);
    $cache->save($pagination);
} else {
    $data = $pagination->get();
}

In redis i see two keys:

  1. "zG3lSHyaSM:\x00tags\x00cache.media.01"
  2. "zG3lSHyaSM:cache.media.01"

First contains: "a:2:{s:12:\"cache.media.\";i:0;s:13:\"cache.media.0\";i:0;}"
Second contains cache data;
Then i call cache clearing by tags:
(new TagAwareAdapter($this->get('cache.app')))->invalidateTags([PostTypeDictionary::CACHE_MEDIA_PREFIX]);
Redis store one more key "zG3lSHyaSM:cache.media.\x00tags\x00", which contains: "i:1;"

And that's all, old cache available.
Another cache adapters have the same problem.
What i'm doing wrong?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 15, 2018

Nothing, that's how things work: invalidated items are not removed from the storage. But when you fetch them, they're still "not found", which is the expected side effect of invalidation.

@byvlad
Copy link
Author

byvlad commented May 15, 2018

@nicolas-grekas but they don't still "not found"

@nicolas-grekas
Copy link
Member

Oh, then you might have hit #27147, which will be fixed in 3.4.10 by #27158.
Does it work when applying the patch or downgrading to 3.4.8?

@byvlad
Copy link
Author

byvlad commented May 15, 2018

@nicolas-grekas I will wait 3.4.10, thank you!

@byvlad byvlad closed this as completed May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants