feat(cache): add deleteMatching method to remove multiple cache items#4567
Merged
paulbalandan merged 5 commits intocodeigniter4:developfrom Apr 20, 2021
Merged
Conversation
5d1e402 to
29d161c
Compare
paulbalandan
requested changes
Apr 17, 2021
Member
paulbalandan
left a comment
There was a problem hiding this comment.
I maintain my stance on not adding this to the interface. Following semver, minor releases should have no breaking changes.
Furthermore, please adjust your failing tests.
… at once using a glob pattern The implementation is only effective for file and redis/predis handlers. Because of certain limitations, memcached and wincache handlers do not implement the method. Both would require to go through the whole cache store (if it ever could) and match each keys against the glob pattern. That would inevitably result in performance issues.
fix memcached tests by checking if it throws an exception
7dfd1c8 to
3a42db1
Compare
Contributor
Author
|
@paulbalandan I've made the requested changes. Sorry for the failing tests, didn't pay attention... I think all should be ok now, could you please take a look? |
Contributor
Author
|
Apparently SQLSRV tests are failing because no connection could be established to the database... |
paulbalandan
approved these changes
Apr 19, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add deleteMatching() method to cache service
Description
Maintaining a big number of cache keys with dependencies to each other can be a hassle with the current existing methods in the cache service.
This feature allows for deleting multiple cache items at once using a glob pattern:
To handle cache dependencies, CI4 users would be able to structure their cache items with the same key prefix and delete the whole "pack" in one go.
Initially discussed in this post: https://forum.codeigniter.com/thread-77789-post-380976.html and on Slack.
Limitations
The implementation is only effective for file and redis/predis handlers.
Because of certain limitations, memcached and wincache handlers do not implement the method.
Both would require to go through the whole cache store (if it ever could) and match each keys
against the glob pattern. That would inevitably result in performance issues.
Also, correct me if I'm wrong, I believe memcached and wincache are not used as much as file and redis handlers. That being said, knowing the limitations and documenting them well would allow users to have access to this feature. That could remove some of the heavy load of having to maintain cache items and dependencies between them.
Any feedback is welcome!
Checklist: