Or does it create a copy of whatever is stored and add this to the script's local memory?
I have a case in which I'm deciding whether to use APCu to cache a seldom changed variable (once a month), or just to re-declare that variable at run time (optimised with OpCache), and upload a new PHP script whenever I change it.
As @zerkmes mentions in his comment, apc_fetch passing references should not be the expected behavior, due to each script having a fixed block of allocated memory.
I've found an experiment (posted by aktharmiah at gmail dot com) in the comments section of: http://php.net/manual/en/function.apc-fetch.php which confirms this:
class foo{
public $bar;
}
apc_add("foo", new foo());
$fooGot = apc_fetch("foo");
$fooGot->bar = 1234;
print_r(apc_fetch("foo"));
echo '<br>';
print_r($fooGot);
Indeed prints:
foo Object ( [bar] => )
foo Object ( [bar] => 1234 )