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

Add delete_multi method to cache #36927

Merged
merged 1 commit into from Aug 26, 2019
Merged

Conversation

peterzhu2118
Copy link
Contributor

@peterzhu2118 peterzhu2118 commented Aug 13, 2019

Summary

Adds ActiveSupport::Cache::Store#delete_multi to delete an array of keys from the cache.

For most implementations, this just calls ActiveSupport::Cache::Store#delete n times, but Redis supports deleting an array of keys. This can improve performance because it turns what is previously n delete calls into a single call.

Memcached does not support multi delete.

Copy link
Member

@jeremy jeremy left a comment

Nice feature! Observe the interaction between read_multi (public API implemented once in base class) and read_multi_entries (private implementation; default in base class, overridden in subclasses). You can follow this pattern with delete_multi (public API) and delete_multi_entries (private implementation) as well.

@peterzhu2118 peterzhu2118 force-pushed the cache-delete-multi branch 4 times, most recently from e0bcb4e to a862d59 Compare Aug 15, 2019
@peterzhu2118
Copy link
Contributor Author

@peterzhu2118 peterzhu2118 commented Aug 15, 2019

Hey @jeremy, thanks for the review! I've updated the implementation with your suggestions, please take another look!

@peterzhu2118
Copy link
Contributor Author

@peterzhu2118 peterzhu2118 commented Aug 20, 2019

Hey @jeremy, could I get another review please?

@jeremy jeremy merged commit 59e746d into rails:master Aug 26, 2019
2 checks passed
@jewilmeer
Copy link

@jewilmeer jewilmeer commented Sep 20, 2019

Awesome! We used a custom implementation and can now switch back to the default again! Thanks @peterzhu2118

@cache.write("foo", "bar")
assert @cache.exist?("foo")
@cache.write("hello", "world")
assert @cache.exist?("foo")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it it the good assertion here?

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

Successfully merging this pull request may close these issues.

None yet

4 participants