Update readme to include fetch#37
Open
ready4god2513 wants to merge 3 commits intopamelafox:masterfrom
Open
Conversation
1dd7c92 to
fe7b5ee
Compare
Owner
|
Interesting! Thank you for the tests and documentation. My main concern is the naming, as memcache.fetch() doesn't do that, and it wasn't obvious to me until I looked at the docs+examples. How did you come up with fetch, is that based on similar APIs that you've used? Were there any other names you considered? |
Author
|
Hello Pamela. Yes, it is a fairly common idiom, however I definitely could see it being confusing and am completely open to a name change on that. One of the first places that I saw this process used is in Rails. Here is a little bit of information- http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-fetch |
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.
Often times I will want to add something to the cache only if it is not yet set. I can make this two different calls, but doing so gets a bit repetitive and unwieldy.
fetchwraps the two method calls up in to a single call with a callback to run if they key is not found.