APC?
It works differents from memcached; in memcached you can access the data from various languages (c, python, etc..) while APC works only for PHP.
EDIT are you sure that APC is installed correctly?
Did you add extension=apc.so
in your php.ini? And to restart apache (im assuming youre on a lamp server with apache2)? What does you phpinfo();
say about APC?
This is a simply test that work perfectly for me:
<?php
/*
* page.php
* Store the variable for 30 seconds,
* see http://it.php.net/manual/en/function.apc-add.php
* */
if(apc_add('foo', 'bar', 30)){
header('Location: page2.php');
}else{
die("Cant add foo to apc!");
}
<?php
/*
* page2.php
* */
echo 'foo is been set as: ' . apc_fetch('foo');
p.s: i prefer to use apc_add
over apc_store
, but the only difference between them is that apc_add doesnt overwrite the variable but will fail if called twice with the same key:
Store the variable using this name. keys are cache-unique, so attempting to use apc_add() to store data with a key that already exists will not overwrite the existing data, and will instead return FALSE. (This is the only difference between apc_add() and apc_store().)
It's a matter of taste/task of the script, but the example above works with apc_store too.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…