note 61821 added to function.memcache-add
| From: | adam dot alkins at gmail dot com | Date: | Mon, 13 Feb 2006 05:23:04 +0000 |
| Subject: | note 61821 added to function.memcache-add | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103600@lists.php.net to get a copy of this message | ||
As the documentation notes, this function returns false if it doesn't replace an existing item
(You must have added the item before for replace to work). If you're writing a dynamic
application which for example caches data from an SQL database, your code should look like this.
<?php
if(!$mc->replace('foo', 'bar'))
{
$mc->add('foo', 'bar');
}
?>
This ensures that the memcache server is repopulated properly everytime it is restarted.
----
Server IP: 64.71.164.2
Probable Submitter: 200.108.26.55
----
Manual Page -- http://www.php.net/manual/en/function.memcache-add.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61821
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61821&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61821&report=yes
Search -- http://master.php.net/manage/user-notes.php