APCÊÇÒ»ÖÖphpµÄ»º´æ½â¾ö·½°¸,ĿǰÒÔpecl·½Ê½·¢²¼,ÓÐÏûϢ˵½«»á³öÏÖÔÚphp6°æ±¾µÄÄÚºË.
Ò».°²×°·½·¨
1)´Óhttp://pecl.php.net/package/apcÏÂÔØÏàÓ¦°æ±¾
2)½âѹ
3)½øÈëÔ´ÂëĿ¼
4)Ö´ÐÐphp°²×°Ä¿Â¼ÏµÄbin/phpize
5)./configure --enable-apc --enable-apc-mmap --with-apxs=path-to-apache/bin/apxs --with-php-config=path-to-php/bin/php-config
6)make && make install
7)½«Éú³ÉµÄapc.so¼ÓÔØµ½php.ini(extesion=apc.so,×¢Òâextension_dirµÄÉèÖÃ)
Ò»°ãµØ,±àÒëÉú³ÉµÄ.so»áÔÚphp°²×°Â·¾¶µÄlib/php/extensionsÏÂ
8)ÖØÆô,apache
дһ¸öphpinfo¿´¿´
×¢:windowsÏÂ,Ö»Òªµ½http://snaps.php.net/µÄÏàÓ¦·ÖÖ§ÏÂÏÂÔØphp_apc.dll,ÔÙÔÚphp.iniÖмÓÔØ¼´¿É
¶þ.Ó÷¨
apcµÄÓ÷¨±È½Ï¼òµ¥,Ö»Óм¸¸öº¯Êý,ÁоÙÈçÏÂ
apc_clear_cache() Çå³ýapc»º´æÄÚÈÝ
ĬÈÏ(ÎÞ²ÎÊý)ʱ,Ö»Çå³ýϵͳ»º´æ,ÒªÇå³ýÓû§»º´æ,ÐèÓÃ'user'²ÎÊý
apc_define_constants ( string key, array constants [, bool case_sensitive] )
½«Êý×éconstantsÒÔ³£Á¿¼ÓÈ뻺´æ
apc_load_constants (string Key)
È¡³ö³£Á¿»º´æ
apc_store ( string key, mixed var [, int ttl] )
ÔÚ»º´æÖб£´æÊý¾Ý
apc_fetch ( string key )
»ñµÃapc_store±£´æµÄ»º´æÄÚÈÝ
apc_delete ( string key )
ɾ³ýapc_store±£´æµÄÄÚÈÝ
ÍêÕûÀý×ÓÈçÏÂ:
<?php
//apc test
//constants
$constants = array('APC_FILE' => 'apc.php', 'AUTHOR' => 'tim');
apc_define_constants('numbers', $constants);
apc_load_constants('numbers');
echo 'APC_FILE='.APC_FILE.'<br>';
echo 'AUTHOR='.AUTHOR.'<br>';
//variable
if(!apc_fetch('time1')) apc_store('time1', time());
if(!apc_fetch('time2')) apc_store('time2', time(),2); //set ttl
echo 'time1:'.apc_fetch('time1').'<br>';
echo 'time2:'.apc_fetch('time2').'<br>';
//object
class a{
function b(){return 'i am b in class a';}
}
apc_store('obj',new a());
$a = apc_fetch('obj');
echo $a->b();
echo '<br>';
//array
$arr = array('a'=>'i am a','b'=>'i am b');
apc_store('arr',$arr);
$apc_arr = apc_fetch('arr');
print_r($apc_arr);
?>
Ìáʾ:Äã¿ÉÒÔË¢ÐÂÒ»ÏÂ,¿´tt