note 95061 rejected from function.apc-add by thiago
| From: | thiago@php.net | Date: | Fri, 11 Dec 2009 11:55:25 +0000 |
| Subject: | note 95061 rejected from function.apc-add by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163848@lists.php.net to get a copy of this message | ||
Note Submitter: auhoque at gmail dot com
----
Please note that, the above given example
<?php
$bar = 'BAR';
apc_add('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
$bar = 'NEVER GETS SET';
apc_add('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
?>
Will not display
string(3) "BAR"
string(3) "BAR"
Because you are trying to add different value(or variable) by using same key (named
âfooâ). As per my understanding the output should be
string(3) "BAR"
bool(false)
According to apc_add() specification it is ok. If you want to store value by using same key, your
code should be
<?php
$bar = 'BAR';
apc_add('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
$bar = 'NEVER GETS SET';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));
echo "\n";
?>