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

feat: Implement ability to drop cache keys using combination of OR an… #75

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

KminekMatej
Copy link
Contributor

@KminekMatej KminekMatej commented Jan 4, 2024

Extending $cache->clean(); with possibility to search for tags to drop using AND logic

  • new feature?
  • BC break? no
  • doc PR: nette/docs (not yet, but planned)

Usage:
Dropping entities having tags animal and dog and (brown or white). Will not match entity, tagged animal and dog and black.

$cache = new Cache($this->cacheStorage, "animals");
$cache->clean([
    Cache::Tags => (new CacheSelector())->where("animal")->where("dog")->where(["brown", "white"])
]);
//

Standard behaviour stays unchanged.

@KminekMatej
Copy link
Contributor Author

Documentation planned to create after expected discussion

@JanTvrdik
Copy link
Contributor

Have you considered using adminal-dog as tag instead of having tags animal and dog?

@KminekMatej
Copy link
Contributor Author

@JanTvrdik I did and it works. However this is usable for some simple scenarios like you wrote, but when the logic grows bigger, using this approach makes it way clearer.

In some points, I need to drop all animals, regardless on any other tags they have. In that case, I need to add to newly created dog these tags:

  1. Animal
  2. Animal-Dog
  3. Animal-Dog-Brown

You can imagine that when your orm complexity grows large, this gets a big messy. Way easier solution is then tagging with:

  1. Animal
  2. Dog
  3. Brown

and in different points of application perform drops right the way you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants