Skip to content

Update readme to include fetch#37

Open
ready4god2513 wants to merge 3 commits intopamelafox:masterfrom
ready4god2513:add-fetch-as-wrapper
Open

Update readme to include fetch#37
ready4god2513 wants to merge 3 commits intopamelafox:masterfrom
ready4god2513:add-fetch-as-wrapper

Conversation

@ready4god2513
Copy link
Copy Markdown

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. fetch wraps the two method calls up in to a single call with a callback to run if they key is not found.

@pamelafox
Copy link
Copy Markdown
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?

@ready4god2513
Copy link
Copy Markdown
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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants