note 89745 deleted from function.memcache-add by danbrown

From: Date: Fri, 20 Mar 2009 23:43:03 +0000
Subject: note 89745 deleted from function.memcache-add by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152245@lists.php.net to get a copy of this message
Note Submitter: web_fella at hotmail dot com ---- the example posted by conrad1986 is not a safe lock implementation. If 2 web server threads try to set the same key in memcache, it creates a race condition, because both processes could get past the replace() call, and then both processes would call set. The add example posted by "php at tapirpirates dot net" on 03-Apr-2008 04:32 is safer, because memcache_add combines get and set behavior in one atomic operation.

« previous php.notes (#152245) next »