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

Update readme to include fetch #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ready4god2513
Copy link

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
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
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.

None yet

2 participants