尊龙凯时人生就是搏

ÔõÑùÓÃThinkPHP»º´æÉèÖÃÌáÉýÓ¦ÓóÌÐòµÄÐÔÄÜ

Ò»¡¢»º´æµÄÓÅÊÆ

»º´æÊÖÒÕÊÇÖ¸½«ÅÌËã»úÖеÄЧ¹û´æ´¢ÔÚ»º´æÖÐ £¬ÒÔ±ãÔÚδÀ´ÐèÇóʱ¿ìËÙ»áÉúЧ¹û¡£ÔÚWebÓ¦ÓóÌÐòÖÐ £¬»º´æÓÐÈçÏÂÓÅÊÆ£º

Ìá¸ßÓ¦ÓóÌÐòµÄÏìÓ¦ËÙÂʺÍЧÂÊ

ïÔ̭ЧÀÍÆ÷ºÍÊý¾Ý¿âµÄ¸ººÉ

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

Ìá¸ßÓû§»á¼ûËÙÂʺÍÌåÑé

ÔÚʹÓÃThinkPHP¿ª·¢Ó¦ÓóÌÐòʱ £¬»º´æÊÖÒÕµÄʹÓÃÊǺÜÊÇÐëÒªºÍÖ÷ÒªµÄ¡£

¶þ¡¢ThinkPHP»º´æµÄ·ÖÀà

ÔÚThinkPHP¿ò¼ÜÖÐ £¬»º´æ·ÖΪÈýÀࣺÎļþ»º´æ¡¢Memcache»º´æºÍRedis»º´æ¡£

Îļþ»º´æ

Îļþ»º´æÊǽ«»º´æÊý¾ÝÉúÑÄÔÚÎļþÖÐ £¬¿ÉÒÔ¿ìËٵĽ«Ò»¸öPHPÊý×éÉúÑÄÔÚÓ²ÅÌÖÐ £¬¾ßÓв»ÐèҪװÖøü¶àÈí¼þ¡¢Àû±ãʹÓõÈÓŵã £¬µ«ÓÉÓÚPHP×Ô¼º»º´æº¯Êý²»·ó¸»ºñ £¬ÎÞ·¨¶Ô»º´æ¾ÙÐÐ×Ô¶¯¸üеȲÙ×÷ £¬Òò´ËÔÚ´óÐÍÍøÕ¾Öв»Ì«±»Ê¹Óá£

Memcache»º´æ

MemcacheÊÇÒ»ÖÖ¸ßÐÔÄÜ¡¢ÂþÑÜʽÄڴ湤¾ß»º´æϵͳ £¬¿ÉÓÃÓÚ»º´æÓ¦ÓóÌÐòµÄÊý¾Ý¿âÅÌÎÊЧ¹û¡¢APIŲÓÃЧ¹ûµÈ¡£Ê¹ÓÃTCPÅþÁ¬Í¨Ñ¶ £¬MemcacheµÄÂþÑÜʽ»º´æ½á¹¹¿ÉÒÔÔöÇ¿Êý¾Ý»á¼ûËÙÂÊ»ººÍ´æÈÝÁ¿¡£

Redis»º´æ

RedisÊÇÒ»ÖÖ¸ßÐÔÄܵÄNoSQL¼üÖµ¶Ô´æ´¢Êý¾Ý¿â £¬Ö§³Ö¶àÖÖÊý¾ÝÀàÐÍ£¨×Ö·û´®¡¢ÁÐ±í¡¢ÜöÝÍ¡¢É¢ÁС¢ÓÐÐòÜöÝ͵ȣ© £¬¿ÉÒÔÓÃÓÚ¿ìËÙµÄÅÌÎʺʹ洢Êý¾Ý¡£Í¨¹ýʹÓÃLua¾ç±¾ÓïÑÔ £¬¿ÉÒÔÎÞаµØ²Ù×÷»º´æ £¬²¢ÏÔÖøÔöÇ¿ÁËRedisµÄ¿ÉÀ©Õ¹ÐԺͿɿ¿ÐÔ¡£

Èý¡¢ThinkPHP»º´æÉèÖõÄʹÓÃ

ʹÓÃThinkPHP¿ò¼ÜµÄCacheÀà¿ÉÒÔÇáËɵØÉèÖûº´æ £¬´Ó¶øÈôúÂëÔ½·¢¼òÆÓºÍÎÞа¡£ÎÞÂÛÔÚ¿ØÖÆÆ÷¡¢Ä£°å»òÕßÄ£×ÓµÈÈκεط½ £¬¶¼¿ÉÒÔ»á¼ûÈ«¾ÖµÄCacheÀà¡£

¿ªÆô»º´æ

ÔÚThinkPHPÖÐ £¬¿ÉÒÔʹÓÃÉèÖÃÎļþÀ´¿ªÆô»º´æ¡£Äã¿ÉÒÔÔÚthinkphp/Conf/config.phpÎļþÖоÙÐÐÒÔÏÂÊôÐÔµÄÉèÖãº

‘HTML_CACHE_ON’ => true,     // ¿ªÆô¾²Ì¬»º´æ

‘HTML_CACHE_TIME’ => 60,     // »º´æʱ¼ä

‘HTML_FILE_SUFFIX’ => ‘.html’, // »º´æÎļþºó׺

ÆôÓÃÁ˾²Ì¬»º´æÖ®ºó £¬ËùÓж¯Ì¬Ò³Ã潫±»»º´æ²¢ÌìÉú¾²Ì¬HTMLÎļþ £¬´Ó¶ø¿ÉÏÔÖøÌá¸ßÓ¦ÓóÌÐòµÄÏìÓ¦ËÙÂʺÍЧÂÊ¡£

ʹÓûº´æ

»á¼û»º´æʱ £¬ºÜÈÝÒ×ʹÓÃCacheÀàÖеġ°set()¡±ºÍ¡°get()¡±ÒªÁì¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄÀý×Ó£º

// ÉèÖûº´æ

Cache::set(‘key’, ‘value’, 3600);

// »ñÈ¡»º´æ

$value = Cache::get(‘key’);

ÔÚÕâÀï £¬ÎÒÃÇʹÓÃÁË¡°set()¡±ÒªÁ콫¡°key¡±ºÍ¡°value¡±ÉúÑÄÔÚ»º´æÖÐ £¬²¢ÉèÖûº´æʱ¼äΪ3600Ã루1Сʱ£©¡£Ê¹Óá°get()¡±ÒªÁì¿ÉÒÔ´Ó»º´æÖлñÈ¡¡°key¡±¶ÔÓ¦µÄÖµ¡£

ɨ³ý»º´æ

ÔÚÓ¦ÓóÌÐòÔËÐÐʱ £¬ÓÐʱÐèҪɨ³ý»º´æ¡£ÎªÁËɨ³ý»º´æ £¬ThinkPHPÌṩÁËÒªÁì”clear()”ºÍ”rm()”¡£É¨³ý»º´æÓÐÁ½ÖÖ·½·¨£º

£¨1£©É¨³ýËùÓлº´æ£º

Cache::clear();

£¨2£©É¨³ýÖ¸¶¨»º´æ£º

Cache::rm(‘key’);

ÐèҪעÖصÄÊÇ £¬É¨³ýÖ¸¶¨»º´æʱ £¬Ê¹ÓõÄÊÇ»º´æµÄ¡°key¡±¡£

ÒÔÉϾÍÊÇÔõÑùÓÃThinkPHP»º´æÉèÖÃÌáÉýÓ¦ÓóÌÐòµÄÐÔÄܵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ