note 96278 added to function.memcache-add

From: Date: Thu, 18 Feb 2010 09:16:01 +0000
Subject: note 96278 added to function.memcache-add
Groups: php.notes 
Request: Send a blank email to php-notes+get-166112@lists.php.net to get a copy of this message
Race conditions happen on an heavy load server when more than one thread tries to execute memcache_add. For example if thread A and thread B try to save the same key you can test that sometimes both return TRUE. To have the right behaviour you can verify that the correct value is in the assigned key: <?php function memcache_safeadd(&$memcache_obj, $key, $value, $flag, $expire) { if (memcache_add($memcache_obj, $key, $value, $flag, $expire)) { return ($value == memcache_get($memcache_obj, $key)); } return FALSE; } ?> ---- Server IP: 81.88.49.24 Probable Submitter: 93.45.218.158 ---- Manual Page -- http://www.php.net/manual/en/function.memcache-add.php Edit -- https://master.php.net/note/edit/96278 Del: integrated -- https://master.php.net/note/delete/96278/integrated Del: useless -- https://master.php.net/note/delete/96278/useless Del: bad code -- https://master.php.net/note/delete/96278/bad+code Del: spam -- https://master.php.net/note/delete/96278/spam Del: non-english -- https://master.php.net/note/delete/96278/non-english Del: in docs -- https://master.php.net/note/delete/96278/in+docs Del: other reasons-- https://master.php.net/note/delete/96278 Reject -- https://master.php.net/note/reject/96278 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166112) next »