-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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(cache): add deleteMatching method to remove multiple cache items #4567
feat(cache): add deleteMatching method to remove multiple cache items #4567
Conversation
5d1e402
to
29d161c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@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? |
Apparently SQLSRV tests are failing because no connection could be established to the database... |
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: