Visitar URL original
Api Method "deleteItemsByTagsAll()" removes unrelated items · Issue #713 · TruCopilot/phpfastcache · GitHub
Skip to content

Api Method "deleteItemsByTagsAll()" removes unrelated items #713

Description

@di-rect

When You add multiple items that have their own tag and also share a tag it seems that when you delete an item using deleteItemsByTagsAll(['sharedTag', 'ownTag']) that all items that share 'sharedTag' are also removed.

Following the docs it should only remove items that have multiple tags or all you set for this function, not one or more like deleteItemsByTags() does.

This happens for me on Couchbase buckets.

To Reproduce
Steps to reproduce the behavior:

  1. Save multiple items with a shared tag and their own tag (like ID)
  2. Remove one of the items by it's IDtag and the sharedTag using deleteItemsByTagsAll(['sharedTag', 'ownTag'])

So 10 items should be in total 21 => 10 items, 10 unique tags items, 1 shared tag item

Expected behavior
One item removed and one (unique) tag, so 2 items less in the bucket and the rest should stay

Current behavior
All items that share the shared tags are removed, so also are their individual tags.

Activity

  1. self-assigned this
    on Nov 29, 2019
  2. Geolim4 commented on Nov 29, 2019

    @Geolim4
    Member

    Hello,

    I don't have much time actually, can you give me a sample of code so I can test it quickly ?

    Cheers,
    Georges

  3. di-rect commented on Nov 30, 2019

    @di-rect
    Author

    Hello,

    I don't have much time actually, can you give me a sample of code so I can test it quickly ?

    Cheers,
    Georges

    Hi,

    Not by hand but I think your increment, or one of the other examples, fits. I see if I can make one out of it.

    Regards,

  4. Geolim4 commented on Dec 2, 2019

    @Geolim4
    Member

    Hmmm I think I know why we have this kind of behavior:

    Item A with tags "shared"
    Item B with tags "shared, custom"

    • I check if the item's tags are all effectively in the deleteItemsByTagsAll(['shared')] request. Which is the case: A and B own this tag.

    But B has also an additional tag: "custom" which is ignored, why ?
    If the scenario was the following:

    Item A with tags "shared, shared2"
    Item B with tags "shared, custom"

    If deleteItemsByTagsAll(['shared, shared2')] was called, only the item A would be deleted, because B doesn't have the tag "shared2"

    In a nutshell: When deleteItemsByTagsAll() is called, I'm checking for the presence of all requested tags, but I'm not checking if all the tags in the ITEM are in the REQUEST.

    This strange behavior will be fixed as soon I can.
    Cheers,
    Georges

  5. Geolim4 commented on Dec 2, 2019

    @Geolim4
    Member

    I think that all *ItemsByTagsAll() methods are affected by this, can you confirm this behavior to me @di-rect ?

  6. di-rect commented on Dec 2, 2019

    @di-rect
    Author

    @Geolim4 thanks for the feedback, sounds reasonable why it happened.

    I cannot confirm if this happens with all *ItemsByTagsAll() I think I can test that for you but don't use them as I don't have a use-case form them in this stadium yet.

    Have you seen the same behavior ?

  7. Geolim4 commented on Dec 3, 2019

    @Geolim4
    Member

    Have you seen the same behavior ?

    I can't test it right now, this is the reason I'm asking you more details :)

  8. di-rect commented on Dec 3, 2019

    @di-rect
    Author

    Have you seen the same behavior ?

    I can't test it right now, this is the reason I'm asking you more details :)

    I need to see if I can make an in-code test-case. Otherwise I can try to make one but I found this out in the heat of the moment as well so I keep this open and I try to test it out as well.

    If I'm right I need to create one, let me try to focus on that tomorrow.

  9. changed the title [-]deleteItemsByTagsAll() removes unrelated items[/-] [+]Api Method "deleteItemsByTagsAll()" removes unrelated items[/+] on Dec 3, 2019
  10. 22 remaining items

  11. Geolim4 commented on Jan 2, 2020

    @Geolim4
    Member

    Hello !!

    🆕 in V8: Multiple strategies ($strategy) are now supported for tagging:

    • TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE allows you to get cache item(s) by at least ONE of the specified matching tag(s). Default behavior.
    • TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL allows you to get cache item(s) by ALL of the specified matching tag(s) (the cache item can have additional tag(s))
    • TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY allows you to get cache item(s) by ONLY the specified matching tag(s) (the cache item cannot have additional tag(s))

    This has been implemented as of the API v3

    • [BC] Removed ExtendedCacheItemPoolInterface::appendItemsByTagsAll() (replaced by strategy TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL)
    • [BC] Removed ExtendedCacheItemPoolInterface::decrementItemsByTagsAll() (replaced by strategy TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL)
    • [BC] Removed ExtendedCacheItemPoolInterface::deleteItemsByTagsAll() (replaced by strategy TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL)
    • [BC] Removed ExtendedCacheItemPoolInterface::getItemsByTagsAll() (replaced by strategy TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL)
    • [BC] Removed ExtendedCacheItemPoolInterface::incrementItemsByTagsAll() (replaced by strategy TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL)
    • [BC] Removed ExtendedCacheItemPoolInterface::prependItemsByTagsAll() (replaced by strategy TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL)
    • Added strategyTaggableCacheItemPoolInterface::TAG_STRATEGY_ONE usable in every **byTags** methods.
    • Added strategyTaggableCacheItemPoolInterface::TAG_STRATEGY_ALL usable in every **byTags** methods.
    • Added strategyTaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY usable in every **byTags** methods.

    Expect the V8 to be released by the summer 2020 :)

    Cheers,
    Georges

  12. di-rect commented on Jan 30, 2020

    @di-rect
    Author

    Sorry for my late response, but this is great!

    Is V8 already usable without being released ?

    Thanks a lot!

  13. Geolim4 commented on Jan 30, 2020

    @Geolim4
    Member

    Sorry for my late response, but this is great!

    Is V8 already usable without being released ?

    Thanks a lot!

    Hello, nope it's still in development status, despite the tests are ok, I would not recommend it for use in a production environment !

    I still have a bunch of docs & tests to made.

  14. di-rect commented on Feb 5, 2020

    @di-rect
    Author

    Hi,

    I got mentioned by someone (that was involved here), maybe this is usable for this as well to make dev easier ? https://github.com/team-a-pro/collection

  15. Geolim4 commented on Feb 5, 2020

    @Geolim4
    Member

    See the discussion above :)

  16. di-rect commented on Feb 5, 2020

    @di-rect
    Author

    See the discussion above :)

    I know but I meant if future development makes it easier why not switch instead ? Not that it's needed, if it saves time I would say... a refactor is never a bad learning curve :)

  17. Geolim4 commented on Feb 5, 2020

    @Geolim4
    Member

    Yes it does what you meant, because the tags now supports all possible use cases. It is implemented in V8 because it's not backward compatible and would break the SemVer.

  18. Geolim4 commented on Feb 5, 2020

    @Geolim4
    Member
  19. di-rect commented on Feb 6, 2020

    @di-rect
    Author

    Which is great! I though I just notice you when you want to be 'lazy' in the future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions