note 89005 modified in function.memcache-add by thiago

From: Date: Wed, 18 Feb 2009 12:10:42 +0000
Subject: note 89005 modified in function.memcache-add by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150790@lists.php.net to get a copy of this message
If you want to add an entry without using the locking method below (takes up extra space), try it this way: <?php if(!$mc->replace("key", $data)) $mc->set("key", $data; ?> That way it will simply try to overwrite the value if a user has already (re)created the key. This is best in high-traffic sites where a user set()'s the data while another user has already tried a get() check and found nothing. Even this method still leaves a small microsecond window open for the same thing. However it helps prevent nasty glitches with submitting multiple entries after a get() check and the system has taken time to recompile the data to send to Memcached, after another user's request has processed this transaction. --was-- If you want to add an entry without using the locking method below (takes up extra space), try it this way: if(!$mc->replace("key", $data)) $mc->set("key", $data; That way it will simply try to overwrite the value if a user has already (re)created the key. This is best in high-traffic sites where a user set()'s the data while another user has already tried a get() check and found nothing. Even this method still leaves a small microsecond window open for the same thing. However it helps prevent nasty glitches with submitting multiple entries after a get() check and the system has taken time to recompile the data to send to Memcached, after another user's request has processed this transaction. http://php.net/manual/en/function.memcache-add.php

« previous php.notes (#150790) next »