colinmollenhour / Cm_Cache_Backend_Redis

A Zend_Cache backend for Redis with full support for tags (works great with Magento)
Other
390 stars 142 forks source link

Remove set instead of removing set members if only one tag #162

Open joshua-bn opened 3 years ago

joshua-bn commented 3 years ago

https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/blob/1132d905f08e33f24d1d80b775d2c7720b00c239/Cm/Cache/Backend/Redis.php#L748

If we only have one cache tag (I think that's the usual case, at least for Magento), we can just remove this instead of removing the set members, right?

colinmollenhour commented 3 years ago

The _notMatchingTags flag is disabled by default so this code would not have any effect unless it is enabled by the user. When enabled it keeps track of all ids in a separate set so that it is efficient to do a "not matching tags" cache clear. Otherwise it would be very time consuming to get all ids. This is a lot of overhead though which is why it's disabled by default.

I've seen plenty of cases where there are multiple tags used so I don't think any such assumptions can be made safely, at least not for a general-purpose library.