Web page inconsistancy

Tim Yardley liquid@haveheart.com
Thu, 1 Jan 2004 18:23:16 -0600

On http://www.danga.com/memcached/... In the "Porting the Application"
section, it shows an example get_foo_object function.  In there, it does an
explicit memcache set for the object.  Further down, in the "What about race
conditions?" section, it says that get_foo type functions should use add and
update_foo functions should use set.

This obviously doesn't line up, but it begs the question of why you would
want to do a set over an add.  My rationale is as follows, if you are in an
update_foo(), then you know you have the latest data, so you want to set.
If you are in a get_foo(), and had to get the latest data from the DB, you
might think you would want to do  a set, but in the time that the select
returned, the data could have changed... So logic says to use add.  I assume
this is the same logic that Brad used, based on the "race conditions"

With that said, the example should therefore reflect the best practice, or
proper use. :)