尊龙凯时人生就是博

ThinkPHP6ÖÐÔõÑùʵÏÖÂþÑÜʽ²Ù×÷ £¿

Ëæ×Å»¥ÁªÍøÉú³¤µÄÈÕÒæѸËÙ £¬ÐèÒª´¦ÀíµÄÊý¾ÝÁ¿Ò²Ô½À´Ô½´ó £¬¼òµ¥Ð§ÀÍÆ÷ÒѾ­ÎÞ·¨Öª×ãÕâÑùµÄÐèÇó £¬ÂþÑÜʽ¼Ü¹¹ÒѾ­³ÉΪÏàʶ¾ö¼Æ»®Ö®Ò»¡£thinkphp×÷Ϊһ¿îÆÄÊܽӴýµÄphp¿ò¼Ü £¬×ÔȻҲÐèÒªÄܹ»Ö§³ÖÂþÑÜʽ²Ù×÷²Å»ªË³Ó¦ÏÖ´ú»¯µÄÉú³¤ÐèÇó¡£ÄÇô £¬ÔõÑùÔÚthinkphp6ÖÐʵÏÖÂþÑÜʽ²Ù×÷ÄØ £¿

1.Êý¾Ý¿âÂþÑÜʽ

Êý¾Ý¿âÂþÑÜʽÊdz£¼ûµÄÂþÑÜʽ½â¾ö¼Æ»®Ö®Ò» £¬ThinkPHP6Ò²ÌṩÁËÏìÓ¦µÄÖ§³Ö¡£Ê×ÏÈ £¬ÔÚconfig/database.phpÎļþÖÐÉèÖöà¸öÊý¾Ý¿â£º

// ĬÈÏÊý¾Ý¿âÉèÖÃ
'default'     => env('database.driver', 'mysql'),

// Êý¾Ý¿âÁбí
'connections' => [
    // Êý¾Ý¿â1
    'mysql1'    => [
        'type'            => 'mysql',
        'hostname'        => '127.0.0.1',
        'database'        => '',
        'username'        => '',
        'password'        => '',
        'hostport'        => '',
        'dsn'             => '',
        'params'          => [],
        'charset'         => 'utf8mb4',
        'prefix'          => '',
        'debug'           => env('app_debug', false),
        'deploy'          => 0,
        'rw_separate'     => false,
        'master_num'      => 1,
        'slave_no'        => '',
        'read_consistent' => false,
        'proxy'           => '',
    ],

    // Êý¾Ý¿â2
    'mysql2'    => [
        // ...
    ],

    // ...
],

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´ £¬ÔÚmodelÀàÖÐʹÓãº

protected $connection = 'mysql1';

µÇ¼ºó¸´ÖÆ

ÕâÑù £¬ÔÚÖ´ÐÐÊý¾Ý¿â²Ù×÷ʱ¾Í»áÅþÁ¬µ½Ö¸¶¨µÄÊý¾Ý¿âÁË £¬¿ÉÒÔÔÚ²î±ðµÄÊý¾Ý¿âÖ®¼äʵÏÖÊý¾ÝµÄÂþÑÜʽ´æ´¢ºÍ»á¼û¡£

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

2.»º´æÂþÑÜʽ

»º´æÂþÑÜʽҲÊǽÏΪ³£¼ûµÄÂþÑÜʽ¼Æ»®Ö®Ò» £¬ThinkPHP6Ò²ÓÐÏìÓ¦µÄ»º´æÂþÑÜʽ֧³Ö¡£ÔÚconfig/cache.phpÎļþÖÐÉèÖöà¸ö»º´æЧÀÍÆ÷£º

// ĬÈÏ»º´æÇý¶¯
'default' => env('cache.driver', 'file'),

// »º´æÁбí
'stores'  => [
    // »º´æ1
    'redis1'   => [
        'type'       => 'redis',
        'hostname'   => '127.0.0.1',
        'port'       => 6301,
        'password'   => '',
        'select'     => 0,
        'timeout'    => 0,
        'expire'     => 0,
        'persistent' => false,
        'prefix'     => 'tp6_',
        'serialize'  => [],
    ],

    // »º´æ2
    'redis2'   => [
        // ...
    ],

    // ...
],

µÇ¼ºó¸´ÖÆ

ÔÚ»º´æÀàÖÐʹÓãº

Cache::store('redis1')->set('key', 'value');

µÇ¼ºó¸´ÖÆ

ͬÑùÒ²¿ÉÒÔÔÚ²î±ðµÄ»º´æЧÀÍÆ÷Ö®¼äʵÏÖÊý¾ÝµÄÂþÑÜʽ´æ´¢ºÍ»á¼û¡£

×ÜÖ® £¬ThinkPHP6ÖÐʵÏÖÂþÑÜʽ²Ù×÷Ïà¶ÔÀ´Ëµ½ÏÁ¿¼òÆÓ £¬Ö»ÐèÒªÔÚ¿ò¼ÜÌṩµÄÉèÖÃÎļþÖÐÉèÖÃÏìÓ¦µÄÐÅÏ¢¼´¿É £¬²¢ÇÒ²î±ðµÄÂþÑÜʽ¼Æ»®¶¼ÓÐÏìÓ¦µÄÖ§³Ö¡£ÈôÊÇÐèÒª¸ü¶àµÄ¶¨ÖÆ»¯²Ù×÷ £¬¿ÉÒÔÔÚ¿ò¼ÜÖÐ×ÔÐÐʵÏÖÏìÓ¦µÄÂþÑÜʽ×é¼þ¡£

ÒÔÉϾÍÊÇThinkPHP6ÖÐÔõÑùʵÏÖÂþÑÜʽ²Ù×÷ £¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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