lscache
lscache copied to clipboard
Update readme to include fetch
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.
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?
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