尊龙凯时人生就是搏

ÔõÑùÔÚThinkPHP6ÖÐʹÓÃRedis¾ÙÐлº´æ²Ù×÷ £¿

Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤£¬ÍøÕ¾µÄ»á¼ûÁ¿Ò²Ô½À´Ô½¸ß£¬Õâ¸øÍøÕ¾µÄÐÔÄÜ´øÀ´Á˺ܴóµÄÌôÕ½¡£ÎªÁËÌá¸ßÍøÕ¾µÄ»á¼ûËÙÂÊ£¬Ðí¶àÍøÕ¾¶¼½ÓÄÉÁË»º´æÊÖÒÕ¡£¶øredis×÷ΪһÖÖ¸ßÐÔÄÜ¡¢ÄÚ´æ´æ´¢Êý¾Ý¿â£¬±»ÆÕ±éÓ¦ÓÃÓÚ»º´æ¡¢ÐÂÎÅÐÐÁС¢Î»ÖÃÐÅÏ¢µÈ³¡¾°¡£

ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝÔõÑùÔÚThinkPHP6ÖÐʹÓÃRedis¾ÙÐлº´æ²Ù×÷¡£

×°ÖÃRedisÀ©Õ¹

Ê×ÏÈ£¬ÐèÒªÔÚphp.iniÎļþÖÐÆôÓÃRedisÀ©Õ¹¡ £¿ÉÒÔͨ¹ýÒÔÏ·½·¨×°ÖÃRedisÀ©Õ¹£º

pecl install redis

µÇ¼ºó¸´ÖÆ

ÈôÊÇÎÞ·¨ÀÖ³É×°Öã¬Ôò¿ÉÒÔÊÖ¶¯ÏÂÔØRedisÀ©Õ¹µÄÔ´Âë¾ÙÐÐ×°Öã¬ÏêϸҪÁìÇë²Î¿¼¹Ù·½Îĵµ¡£

×°ÖÃÍê³Éºó£¬ÔÚphp.iniÎļþÖÐÌí¼ÓÒ»ÐÐÉèÖãº

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

extension=redis.so

µÇ¼ºó¸´ÖÆ

ÖØÆôPHPºó¼´¿ÉʹÓÃRedis¡£

ÉèÖÃRedis

ÔÚThinkPHP6ÖУ¬¹ØÓÚRedisµÄÉèÖö¼ÔÚconfig/cache.phpÎļþÖС£Ê×ÏÈ£¬ÐèҪȷ±£cache.phpÎļþÖеÄRedisÇý¶¯±»ÆôÓãº

'default' => [
 'type'  => 'redis',
 ...
]

µÇ¼ºó¸´ÖÆ

È»ºó£¬ÐèÒªÉèÖÃRedisµÄÅþÁ¬ÐÅÏ¢£¬ÈçÏ£º

'default' => [
 'type'  => 'redis',
 'host'  => '127.0.0.1',
 'port'  => 6379,
 'password' => '',
 'select' => 0,
 'timeout' => 0,
 'expire' => 0,
 'persistent' => false,
 'prefix' => '',
],

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬’host’ÌåÏÖRedisµÄIPµØµã»òÖ÷»úÃû£¬’port’ÌåÏÖRedisµÄ¶Ë¿ÚºÅ£¬’password’ÌåÏÖÅþÁ¬RedisʱµÄÃÜÂ룬’select’ÌåÏÖÑ¡ÔñµÄÊý¾Ý¿â±àºÅ£¬’timeout’ÌåÏÖÅþÁ¬³¬Ê±Ê±¼ä£¬’expire’ÌåÏÖ»º´æÓÐÓÃʱ¼ä£¬’prefix’ÌåÏÖ»º´æǰ׺¡£

ʹÓÃRedis¾ÙÐлº´æ²Ù×÷

ÔÚÉèÖÃÍê³Éºó£¬¼´¿ÉʹÓÃRedis¾ÙÐлº´æ²Ù×÷¡£¹ØÓÚThinkPHP6ÖеĻº´æ²Ù×÷£¬¿ÉÒÔʹÓÃcacheº¯Êý¾ÙÐÐŲÓá£ÀýÈ磺

cache('key_name', 'value', 3600);

µÇ¼ºó¸´ÖÆ

Ôò»á½«’value’»º´æµ½RedisÖУ¬ÓÐÓÃÆÚΪ3600Ãë¡£ÈôÊÇÏëҪȡ³ö»º´æÊý¾Ý£¬¿ÉÒÔʹÓÃÒÔÏ·½·¨£º

$value = cache('key_name');

µÇ¼ºó¸´ÖÆ

¼´¿É´ÓRedisÖÐÈ¡³ö»º´æÊý¾Ý¡£

ͬʱ£¬»¹¿ÉÒÔʹÓÃRedisÌṩµÄÆäËûAPI¾ÙÐлº´æ²Ù×÷£¬ÀýÈçset¡¢getµÈÒªÁì¡£ÏêϸµÄ²Ù×÷Çë²Î¿¼Redis¹ÙÍøÎĵµ¡£

×ܽá

ͨ¹ý±¾ÎĵÄÏÈÈÝ£¬ÐÅÍи÷ÈËÒѾ­ÕÆÎÕÁËÔÚThinkPHP6ÖÐʹÓÃRedis¾ÙÐлº´æ²Ù×÷µÄÒªÁ졣ʹÓÃRedis¾ÙÐлº´æ¿ÉÒÔ´ó´óÌá¸ßÍøÕ¾µÄÐÔÄÜ£¬¼õÇáЧÀÍÆ÷µÄ¼ç¸º£¬ÊÇÏÖ´úÍøÕ¾±ØÐèµÄÊÖÒÕÖ®Ò»¡£

ÒÔÉϾÍÊÇÔõÑùÔÚThinkPHP6ÖÐʹÓÃRedis¾ÙÐлº´æ²Ù×÷ £¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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