Skip to content
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

Deleting cache by tag without loading all its cache #900

Closed
mlavrinenko opened this issue Apr 12, 2023 · 3 comments
Closed

Deleting cache by tag without loading all its cache #900

mlavrinenko opened this issue Apr 12, 2023 · 3 comments

Comments

@mlavrinenko
Copy link

What's your question ?

Hello!

TaggableCacheItemPoolTrait->deleteItemsByTags loads all tag items and then deletes them. It can lead to high memory usage.

I cache a lot of fragile data. Any change in one piece of data should delete all tagged cache entirely. I considered the clear method, but I have some exceptions when some chunks of data isn't fragile and should survive such a cleanup.

CacheDeleteItem event can still be dispatched, but with lazy loading object passed to it. That means if there is no event handlers then no data will be loaded from driver.

Or I just miss something?

References (optional)

public function deleteItemsByTags(array $tagNames, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool

Do you have anything more you want to share? (optional)

No response

@github-actions
Copy link

Hello curious contributor !
Since it seems to be your first contribution, make sure that you've been:

  • Reading and searching out our WIKI
  • Reading and agreed with our Code Of Conduct
  • Reading and understood our Coding Guideline
  • Reading our README
    If everything looks unclear to you, tell us what 😄
    The Phpfastcache Team

@Geolim4
Copy link
Member

Geolim4 commented Apr 23, 2023

Hello,

Sorry for late reply.
The choice of loading cache item tags into the memory was because not all backends (like Redis) do support cache tags operations.

That means you need to handle them on the phpfastcache-level for others backends.

I wisely made the choice years ago because it was easier to implements and completely transparent for the developer.

I advice you to split your "crucial data" to a new different cache instance of phpfastcache that will survive even if your clear the data of your other cache instance.

Cheers,
Georges

@Geolim4
Copy link
Member

Geolim4 commented Jul 5, 2023

Hello @mlavrinenko,

I’m closing this issue for now because of (inactivity / outdated code / …).

You can always reopen it though! :)
Please (update the issue / add comment / clarify …).

Regards,
Georges.L

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

2 participants