note 89005 deleted from function.memcache-add by danbrown
| From: | danbrown@php.net | Date: | Sat, 19 Jun 2010 03:52:53 +0000 |
| Subject: | note 89005 deleted from function.memcache-add by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-170266@lists.php.net to get a copy of this message | ||
Note Submitter: conrad1986 at gmail dot com
----
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.