ÉîÈë½âÎöphpÖ®apc

5年以前  |  阅读数:356 次  |  编程语言:PHP 

apc¶¨Òa£ºapcÊÇÒ»¸o¿ªÅ×ÔÓɵÄphp opcode»º´ae¡£ËuµÄÄ¿±eÊÇÌa¹(C)Ò»¸o×ÔÓÉ¡¢¿ªÅºÍ½¡È«µÄ¿o¼Ü£¬ÓÃÓÚ»º´aeºÍÓÅ»¯phpÖмa´uÂe¡£
apc³£Óú¯Êý£º
1.apc_clear_cache() Ça³þapc»º´aeÄÚÈÝ
2.apc_define_constants(string key,array constants,[,bool case_sensitive]) ½«Êý×econstantsÒÔ³£Á¿¼ÓÈe»º´ae
3.apc_load_constants(string key) È¡³o³£Á¿»º´ae
4.apc_store(string key,mixed var [, int ttl]) ÔÚ»º´aeÖб£´aeÊý¾Ý
5.apc_fetch(string key) »ñÈ¡apc_store±£´aeµÄ»º´aeÊý¾Ý
6.apc_delete(string key) ɾ³ýapc_store±£´aeµÄÄÚÈÝ
7.apc_add(string key,mixd var [, int ttl]) »º´aeÒ»¸o±aÁ¿µ½Êý¾Ý´ae´¢£¨Ö»ÔÚ±aÁ¿Ö®Ç°Ã»Óб»´ae´¢µÄÇe¿o£(C)
8.apc_exists(mix keys) ¼i²eÊÇñÓÐÒ»¸o»oÕ߶a¸oapc¼uÃu´aeÔÚ
9.apc_delete_file(mixed keys) ´Óopcode»º´aeÖÐɾ³ý¸ø¶¨ÎļþµÄ»º´ae
10.apc_compile_file(string filename [,bool atmic=true]) ÈƹýfiltersµÄÏÞÖÆ£¬»º´aeÎļþ
11.apc_cache_info(string cache_type [,bool limited=false]) »ñÈ¡»º´aeiÐÍÄÌÎo
×¢£ºapc_clear_cacheÖ»Ça³ýopcode»º´aeÎļþ£¬apc_deleteÇa³þ»º´aeÖеıaÁ¿£»Ô¤¶¨Òa±aÁ¿£¬¿ÉÒÔʹÓÃapc_define_constantsº¯Êý£»php±aÁ¿¿ÉÒÔʹÓú¯Êýapc_store£¬Ê¹ÓÃapc±Èmemcache»a¸uºÃ£¬²»ÐeÒª¾­¹ýÍøÂç´«ÊaЭÒetcp£»apc²»ÊÊÓÃÓÚͨ¹ýº¯Êýapc_store»º´aeƵ
±±a¸uµÄÓû§Êý¾Ý£¬»a³oÏÖÒ»Ð(C)ÆaeÒiµÄÏÖÏo£»apc±¾Éi²»Ö§³ÖÖ²¼Ê½¡£
apc³£ÓÃÅaÖãº
1.¶aÉÙÄÚ´ae½«±»
ÖÅa¸øapc£¬iniÑ¡Ïiapc.shm_size£¨integer£(C)¿ØÖÆÕa¸oÉeÖá£Ä¬ÈÏΪ30M
2.ÿ´ÎÇeÇoapcÊÇñ¼i²eÎļþÐ޸ģ¬iniÑ¡Ïiapc.stat¿ØÖÆÕa¸oÉeÖã¬Ä¬ÈÏֵΪ1£¬±iʾÿ´ÎÇeÇo½Å±¾Ê±¶¼¼o²u½Å±¾ÊÇñ±»¸uУ¬Èç¹u¸uÐÂÔo×Ô¶¯ÖØбaÒeºÍ»º´ae±aÒeºoµÄÄÚÈÝ£¬¶ÔÐÔÄÜÓбÈÀýµÄÓ°Ïi£¬¹ÊÕa¸oÉeΪ0
3.ͨ¹ýiniÑ¡Ïiapc.filters»º´ae¸uÉٵĽű¾
apcÓŵa£º
1.ʹÓÃspinlocks£¨×ÔÐý£(C)Ëø»uÖÆ£¬Äܹ»´iµ½×i¼ÑÐÔÄÜ
2.apcÌa¹(C)apc.php£¬ÓÃÓÚ¼a¿ØºÍ¹ÜÀiapc»º´ae¡££¨×¢£ºÐ޸ĹÜÀiÔ±ÃuºÍÃÜÂe£(C)
3.apcĬÈÏͨ¹ýmmapÄaÃuÓ³Éa´´½¨¹²ÏiÄÚ´ae£¬»º´ae¶ÔÏo¶¼´aeÅÔÚÕa¿e´oÐ͵ÄÄÚ´ae¿Õ¼a¡£ÓÉapc×ÔÐйÜÀi¸Ã¹²ÏiÄÚ´ae
4.µ÷Õuapc.shm_size¡¢apc.num_files_hints¡¢apc.user_entires_hintµÄÖµµ½×i¼Ñ
5.phpÔ¤¶¨Òa³£Á¿£¬¿ÉÒÔʹÓÃapc _define¡ª¡ªconstants()º¯Êý¡£²»¹ýapc¿ª
¢Õß˵pecl hidefÐÔÄܸu¼Ó£¬Å×Æudefine£¬ËuÊǵÍЧµÄ
6.apc_store£¬¶ÔÓÚϵͳÉeÖõÈPHP±aÁ¿£¬ÉuÃuÖÜÆÚÊÇÕu¸oÓ¦Ó㨴ÓhttpdÊØ»¤½ø³Ìµ½httpdÊØ»¤½ø³Ì¹Ø±Õ£(C)£¬Ê¹ÓÃapc±Èmemcache¸uºÃ¡££¨²»ÐeÒª¾­¹ýÍøÂç´«ÊaЭÒe£(C)
7.apc²»ÊÊÓÃÓÚͨ¹ýº¯Êýapc_store()»º´aeƵ*±±a¸uÓû§Êý¾Ý£¬»a³oÏÖÒ»Ð(C)ÆaeÒiÏÖÏo¡£
Àý£º
<?php
$constants = array('APC_FILE'=>'apc.php','AUTHOR'=>'tim');
apc_define_constants('memb',$constants );
apc_load_constants('memb');
//echo APC_FILE;
//echo AUTHOR;

if(!apc_fetch('time1')) apc_store('time1',time());
if(!apc_fetch('time2')) apc_store('time2',time(),2);
//echo apc_fetch('time1');
//echo apc_fetch('time2');

class a{
public function b(){echo 'success';}
}
apc_store('obj',new a());
$a = apc_fetch('obj');
//$a-b();

$ret = apc_exists(array('foo', 'donotexist', 'bar'));
//array(2) { ["foo"]=> bool(true) ["bar"]=> bool(true) }
?>
²¹³aÏeϸÅaÖÃ˵Ã÷£º
apc.cache_by_default = on
;sys
; ÊÇñĬÈ϶ÔËuÓÐÎļþÆoÓûº³a¡£
; ÈoÉeΪoff²¢ÓeÒԼӺſªÍ
µÄapc.filtersÖ¸ÁiÒ»ÆðÓã¬ÔoÎļþ½oÔÚÆ¥Åa¹ýÂËÆ÷ʱ²Å±»»º´ae¡£

apc.enable_cli = off
;sys
; ÊÇ*ñΪcli°ae±¾ÆoÓÃapc¹¦ÄÜ£¬½oÓÃÓÚ²aÊԺ͵÷ÊÔÄ¿µÄ²Å´o¿ª´ËÖ¸Ái¡£

apc.enabled = on
; ÊÇñÆoÓÃapc£¬Èç¹uapc±»¾²Ì¬±aÒe½øphpÓÖÏe½uÓÃËu£¬ÕaÊÇΨһµÄ°i¨¡£

apc.file_update_protection = 2
;sys
; µ±ÄaÔÚÒ»¸oÔËÐÐÖеÄþÎñÆ÷ÉÏÐÞ¸ÄÎļþʱ£¬ÄaÓ¦µ±Ö´ÐÐÔ­×Ó²Ù×÷¡£
; Ò²¾ÍÊÇÏÈд½øÒ»¸oÁÙʱÎļþ£¬È»ºo½«¸ÃÎļþÖØÃuÃu(mv)µ½×iÖÕµÄÃu×Ö¡£
; Îı¾±a¼­Æ÷ÒÔ¼°cp, tar µÈ³ÌÐoÈ´²¢²»ÊÇÕaÑu²Ù×÷µÄ£¬´Ó¶øµ¼ÖÂÓпÉÄÜ»º³aÁ˲ÐȱµÄÎļþ¡£
; ĬÈÏÖµ2 ±iʾÔÚ
ÃÎÊÎļþʱÈç¹u¢ÏÖÐÞ¸Äʱ¼a¾aÀeÃÎÊʱ¼aСÓÚ2 ÃeÔo²»×o»º³a¡£
; ÄǸo²»ÐÒµÄÃÎÊÕß¿ÉÄܵõ½²ÐȱµÄÄÚÈÝ£¬µ«ÊÇÕaÖÖ»µÓ°ÏiÈ´²»»aͨ¹ý»º´aeÀ(C)´o»¯¡£
; Èç¹uÄaÄÜÈ
±£ËuÓеĸuвÙ×÷¶¼ÊÇÔ­×Ó²Ù×÷£¬ÄÇô¿ÉÒÔÓÃ0 ¹Ø±Õ´ËÌØÐÔ¡£
; Èç¹uÄaµÄϵͳÓÉÓÚ´oÁ¿µÄio²Ù×÷µ¼Ö¸uлºÂý£¬Äa¾ÍÐeÒªÔo´o´ËÖµ¡£

apc.filters =
;sys
; Ò»¸oÒÔ¶ººÅÖ¸oµÄposixÀ(C)Õ¹ÕýÔo±i´iʽÁбi¡£
; Èç¹uÔ´ÎļþÃuÓeÈÎÒaÒ»¸oģʽƥÅa£¬Ôo¸ÃÎļþ²»±»»º´ae¡£
; ×¢Òa£¬ÓÃÀ´Æ¥ÅaµÄÎļþÃuÊÇ´«µÝ¸øinclude/requireµÄÎļþÃu£¬¶ø²»ÊǾø¶ÔÂ
¾¶¡£
; Èç¹uÕýÔo±i´iʽµÄµÚÒ»¸o×ÖuÊÇ"+"ÔoÒaζ×ÅÈκÎÆ¥Åa±i´iʽµÄÎļþ»a±»»º´ae£¬
; Èç¹uµÚÒ»¸o×Ö
uÊÇ"-"ÔoÈκÎÆ¥ÅaÏi¶¼²»»a±»»º´ae¡£"-"ÊÇĬÈÏÖµ£¬¿ÉÒÔÊ¡ÂÔµo¡£

apc.ttl = 0
;sys
; »º´aeÌoÄ¿ÔÚ»º³aÇøÖÐÔÊÐi¶ºÁoµÄÃeÊý¡£0 ±iʾÓÀ²»³¬Ê±¡£½¨ÒeֵΪ7200~36000¡£
; ÉeΪ0 Òaζ×Å»º³aÇøÓпÉÄܱ»¾ÉµÄ»º´aeÌoÄ¿ÌiÂu£¬´Ó¶øµ¼ÖÂÎÞ*¨»º´aeÐÂÌoÄ¿¡£

apc.user_ttl = 0
;sys
; ÀaËÆÓÚapc.ttl£¬Ö»ÊÇÕe¶Ôÿ¸oÓû§¶øÑÔ£¬½¨ÒeֵΪ7200~36000¡£
; ÉeΪ0 Òaζ×Å»º³aÇøÓпÉÄܱ»¾ÉµÄ»º´aeÌoÄ¿ÌiÂu£¬´Ó¶øµ¼ÖÂÎÞ*¨»º´aeÐÂÌoÄ¿¡£

apc.gc_ttl = 3600
;sys
; »º´aeÌoÄ¿ÔÚÀ¬»ø»ØÊÕ±iÖÐÄܹ»´aeÔÚµÄÃeÊý¡£
; ´ËÖµÌa¹(C)ÁËÒ»¸o°²È«´eÊ(C)£¬¼´Ê¹Ò»¸oþÎñÆ÷½ø³ÌÔÚÖ´Ðлº´aeµÄÔ´Îļþʱ±ÀÀ££¬
; ¶øÇÒ¸ÃÔ´ÎļþÒѾ­±»Ð޸ģ¬Îª¾É°ae±¾
ÖÅaµÄÄÚ´aeÒ²²»»a±»»ØÊÕ£¬Ö±µ½´iµ½´ËttlֵΪֹ¡£
; ÉeΪÁa½«½uÓôËÌØÐÔ¡£

apc.include_once_override = off
;sys
; ¹ØÓÚ¸ÃÖ¸ÁiÄ¿Ç°ÉÐÎÞ˵Ã÷Îĵµ£¬²Î¼u£ºhttp://pecl.php.net/bugs/bug.php?id=8754
; Çe±£³ÖΪoff£¬*ñÔo¿ÉÄܵ¼ÖÂÒaÏe²»µ½µÄ½a¹u¡£

apc.max_file_size = 1m
;sys
; ½uÖ¹´oÓڴ˳ߴçµÄÎļþ±»»º´ae¡£

apc.mmap_file_mask =
;sys
; Èç¹uʹÓèCenable-mmap(ĬÈÏÆoÓÃ)Ϊapc±aÒeÁËmmapÖ§³Ö£¬
; ÕaÀiµÄÖµ¾ÍÊÇ´«µÝ¸ømmapÄ£¿eµÄmktempç¸ñµÄÎļþÑÚÂe(½¨ÒeֵΪ"/tmp/apc.xxxxxx")¡£
; ¸ÃÑÚÂeÓÃÓÚ¾o¶¨ÄÚ´aeÓ³ÉaÇøÓoÊÇ
ñÒª±»file-backed»oÕßshared memory backed¡£
; ¶ÔÓÚÖ±½ÓµÄfile-backedÄÚ´aeÓ³Éa£¬ÒªÉeÖóÉ"/tmp/apc.xxxxxx"µÄÑu×Ó(Ç¡ºÃ6¸ox)¡£
; ҪʹÓÃposix*ç¸ñµÄshm_open/mmap¾ÍÐeÒªÉeÖóÉ"/apc.shm.xxxxxx"µÄÑu×Ó¡£
; Äa»¹¿ÉÒÔÉeΪ"/dev/zero"À´ÎªÄaÃuÓ³ÉaµÄÄÚ´aeʹÓÃÄں˵Ä"/dev/zero"½Ó¿Ú¡£
; ²»¶¨Òa´ËÖ¸ÁiÔo±iʾǿÖÆʹÓÃÄaÃuÓ³Éa¡£

apc.num_files_hint = 1000
;sys
; webþÎñÆ÷ÉÏ¿ÉÄܱ»°uº¬»o±»ÇeÇoµÄ²»Í¬Ô´ÎļþµÄ´oÖÂÊýÁ¿(½¨ÒeֵΪ1024~4096)¡£
; Èç¹uÄa²»ÄÜÈ
¶¨£¬ÔoÉeΪ0 £»´ËÉe¶¨Ö÷ÒªÓÃÓÚÓµÓÐÊýǧ¸oÔ´ÎļþµÄÕ¾µa¡£

apc.optimization = 0
; ÓÅ»¯¼¶±ð(½¨ÒeֵΪ0 ) ¡£
; ÕýÕuÊýÖµ±iʾÆoÓÃÓÅ»¯Æ÷£¬ÖµÔ½¸ßÔoʹÓÃÔ½¼¤½øµÄÓÅ»¯¡£
; ¸u¸ßµÄÖµ¿ÉÄÜÓÐ*dz£ÓÐÏÞµÄËÙ¶ÈÌaÉý£¬µ«Ä¿Ç°ÉÐÔÚÊÔÑeÖС£

apc.report_autofilter = off
;sys
; ÊÇ*ñ¼Ç¼ËuÓÐÓÉÓÚearly/late bindingÔ­Òo¶ø×Ô¶¯Î´±»»º´aeµÄ½Å±¾¡£

apc.shm_segments = 1
;sys
; Ϊ±aÒeÆ÷»º³aÇø*ÖÅaµÄ¹²ÏiÄÚ´ae¿eÊýÁ¿(½¨ÒeֵΪ1)¡£
; Èç¹uapcºÄ¾¡Á˹²ÏiÄÚ´ae£¬²¢ÇÒÒѽ«apc.shm_sizeÖ¸ÁiÉeΪϵͳÔÊÐiµÄ×i´oÖµ£¬
; Äa¿ÉÒÔ³¢ÊÔÔo´o´ËÖµ¡£

apc.shm_size = 30
;sys
; ÿ¸o¹²ÏiÄÚ´ae¿eµÄ´oС(ÒÔmbΪµ¥Î»£¬½¨ÒeֵΪ128~256)¡£
; ÓÐÐ(C)ϵͳ(°uÀ¨´o¶aÊýbsd±aÖÖ)ĬÈϵĹ²ÏiÄÚ´ae¿e´oС*dz£ÉÙ¡£

apc.slam_defense = 0
;sys(´¶ÔʹÓøÃÖ¸Ái£¬½¨Òe¸ÃÓÃapc.write_lockÖ¸Ái)
; ÔÚ
dz£±Ã¦µÄþÎñÆ÷ÉÏ£¬ÎÞÂÛÊÇÆo¶¯þÎñ»¹ÊÇÐÞ¸ÄÎļþ£¬
; ¶¼¿ÉÄÜÓÉÓÚ¶a¸o½ø³ÌÆoͼͬʱ»º´aeÒ»¸oÎļþ¶øµ¼Ö¾ºÕuÌo¼þ¡£
; Õa¸oÖ¸ÁiÓÃÓÚÉeÖýø³ÌÔÚ´¦Àiδ±»»º´aeµÄÎļþʱÌø¹ý»º´ae²½ÖeµÄ°Ù
ÖÂÊ¡£
; ±ÈÈçÉeΪ75±iʾÔÚÓoµ½Î´±»»º´aeµÄÎļþʱÓÐ75%µÄ¸ÅÂʲ»½øÐлº´ae£¬´Ó¶ø¼oÉÙÅoײ¼¸ÂÊ¡£
; ¹ÄÀøÉeΪ0 À´½uÓÃÕa¸oÌØÐÔ¡£

apc.stat = on
;sys
; ÊÇñÆoÓýű¾¸uмi²e¡£
; ¸Ä±aÕa¸oÖ¸ÁiÖµÒª
dz£Ð¡ÐÄ¡£
; ĬÈÏÖµon ±iʾapcÔÚÿ´ÎÇeÇo½Å±¾Ê±¶¼¼i²e½Å±¾ÊÇñ±»¸uУ¬
; Èç¹u±»¸uÐÂÔo×Ô¶¯ÖØбaÒeºÍ»º´ae±aÒeºoµÄÄÚÈÝ¡£µ«ÕaÑu×o¶ÔÐÔÄÜÓв»ÀuÓ°Ïi¡£
; Èç¹uÉeΪ off Ôo±iʾ²»½øÐмi²e£¬´Ó¶øʹÐÔÄܵõ½´o
uÌa¸ß¡£
; µ«ÊÇΪÁËʹ¸uеÄÄÚÈÝÉuЧ£¬Äa±ØÐeÖØÆowebþÎñÆ÷¡£
; Õa¸oÖ¸Ái¶ÔÓÚinclude/requireµÄÎļþͬÑuÓÐЧ¡£µ«ÊÇÐeҪעÒaµÄÊÇ£¬
; Èç¹uÄaʹÓõÄÊÇÏa¶ÔÂ
¾¶£¬apc¾Í±ØÐeÔÚÿһ´Îinclude/requireʱ¶¼½øÐмi²eÒÔ¶¨Î»Îļþ¡£
; ¶øʹÓþø¶Ô¾¶Ôo¿ÉÒÔÌø¹ý¼i²e£¬ËuÒÔ¹ÄÀøÄaʹÓþø¶Ô¾¶½øÐÐinclude/require²Ù×÷¡£

apc.user_entries_hint = 100
;sys
; ÀaËÆÓÚnum_files_hintÖ¸Ái£¬Ö»ÊÇÕe¶Ôÿ¸o²»Í¬Óû§¶øÑÔ¡£
; Èç¹uÄa²»ÄÜÈ*¶¨£¬ÔoÉeΪ0 ¡£

apc.write_lock = on
;sys
; ÊÇñÆoÓÃдÈeËø¡£
; ÔÚ
dz£±Ã¦µÄþÎñÆ÷ÉÏ£¬ÎÞÂÛÊÇÆo¶¯*þÎñ»¹ÊÇÐÞ¸ÄÎļþ£¬
; ¶¼¿ÉÄÜÓÉÓÚ¶a¸o½ø³ÌÆoͼͬʱ»º´aeÒ»¸oÎļþ¶øµ¼Ö¾ºÕuÌo¼þ¡£
; ÆoÓøÃÖ¸Ái¿ÉÒÔ±ÜÃa¾ºÕuÌo¼þµÄ³oÏÖ¡£

apc.rfc1867 = off
;sys
; ´o¿ª¸ÃÖ¸Áiºo£¬¶ÔÓÚÿ¸oÇ¡ºÃÔÚfile×Ö¶Î֮ǰº¬ÓÐapc_upload_progress×ֶεÄÉÏ´«Îļþ£¬
; apc¶¼½«×Ô¶¯´´½¨Ò»¸oupload_µÄÓû§»º´aeÌoÄ¿(¾ÍÊÇapc_upload_progress×Ö¶ÎÖµ)¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例