尊龙凯时人生就是搏

Swoole½ø½×£ºÔõÑùʹÓÃЭ³ÌʵÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷

Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤ £¬ÍøÂçÇëÇó±äµÃÔ½À´Ô½ÆµÈÔºÍÖØ´ó £¬ÔõÑùʵÏÖ¸ßЧµÄ²¢·¢Êý¾Ý²Ù×÷ÒѾ­³ÉΪЧÀÍÆ÷¿ª·¢ÕßÃæÁÙµÄÒ»¸öÖ÷ÒªÎÊÌâ¡£ÔڹŰåµÄphp¿ª·¢ÖÐ £¬ÎªÁËʵÏÖ²¢·¢²Ù×÷ £¬ÍùÍùÐèÒª½ÓÄɶàÀú³Ì»ò¶àÏ̵߳ķ½·¨ £¬µ«ÕâÖÖ·½·¨±£´æ×ÅÏÔÖøµÄÐÔÄÜÆ¿¾±ºÍ×ÊÔ´ÆÌÕÅ¡£È»¶ø £¬ÔÚʹÓÃswooleЭ³ÌÖ®ºó £¬¿ª·¢Õß¿ÉÒÔÇáËɵØʵÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷ £¬±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃswooleЭ³ÌʵÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷¡£

Ò»¡¢Ê²Ã´ÊÇSwooleЭ³Ì

SwooleÊÇ»ùÓÚPHPÓïÑÔµÄÍøÂçͨѶ¿ò¼Ü £¬ËüÄÚÖÃÁËЭ³ÌÖ§³Ö £¬¿ÉÒÔ×ÊÖú¿ª·¢ÕßÇáËɵØʵÏÖ¸ßЧµÄÒì²½±à³ÌºÍ²¢·¢²Ù×÷¡£Ð­³ÌÊÇÒ»ÖÖÇáÁ¿¼¶µÄÏß³Ì £¬¿ÉÒÔʵÏÖÔÚÒ»¸öÏß³ÌÖÐÔÚ²î±ðµÄ´úÂë¿éÖ®¼ä¾ÙÐÐÇл» £¬Òò´Ë¿ÉÒÔÔÚµ¥Ïß³ÌÏÂÃæʵÏÖ²¢·¢²Ù×÷¡£SwooleµÄЭ³ÌÄ£¿éÖ÷ÒªÓÐÒÔϼ¸¸ö×é¼þ£º

1¡¢Ð­³Ìµ÷ÀíÆ÷£ºÓÃÓÚЭ³Ì¿ØÖƺÍÇл»¡£

2¡¢Ð­³Ì¿Í»§¶Ë£º¿ÉÒÔʵÏÖЭ³Ì·½·¨ÏµÄÍøÂçͨѶ¡£

3¡¢Ð­³ÌÐźż°×¼Ê±Æ÷£º¿ÉÒÔʵÏÖЭ³Ì·½·¨ÏµÄ׼ʱÆ÷ºÍÐźŴ¦Àí¡£

4¡¢Ð­³ÌSocket¼°HTTPЧÀÍÆ÷£º¿ÉÒÔʵÏÖЭ³Ì·½·¨ÏµÄSocketͨѶºÍHTTPЧÀÍÆ÷¡£

¶þ¡¢Ê¹ÓÃSwooleЭ³ÌʵÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷

ÔÚSwooleЭ³ÌÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃCoun()º¯ÊýÀ´½¨ÉèÒ»¸öЭ³Ì £¬ÀýÈ磺

Coun(function(){
    // do something in coroutine
});

µÇ¼ºó¸´ÖÆ

ÔÚЭ³ÌÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃSwooleÌṩµÄЭ³ÌMySQL¿Í»§¶ËºÍЭ³ÌRedis¿Í»§¶ËÀ´ÊµÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷¡£ÏÂÃæÎÒÃǽ«ÏêϸÏÈÈÝʹÓÃÕâÁ½ÖÖ¿Í»§¶ËµÄÒªÁì¡£

1¡¢Ê¹ÓÃЭ³ÌMySQL¿Í»§¶Ë

ÔÚʹÓÃЭ³ÌMySQL¿Í»§¶Ë֮ǰ £¬ÎÒÃÇÐèÒªÏÈ×°ÖÃswooleÀ©Õ¹ÖеÄmysqlÄ£¿é £¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°Öãº

pecl install swoole_mysql

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³ÉÖ®ºó £¬ÎÒÃǾͿÉÒÔÔÚЭ³ÌÖÐʹÓÃЭ³ÌMySQL¿Í»§¶ËÁË¡£ÏÂÃæÊÇÒ»¸öʹÓÃЭ³ÌMySQL¿Í»§¶ËÅÌÎÊÊý¾ÝµÄÀý×Ó£º

Coun(function(){
    $db = new SwooleCoroutineMySQL();
    $db->connect([
        'host' => '127.0.0.1',
        'port' => 3306,
        'user' => 'root',
        'password' => '123456',
        'database' => 'test',
    ]);
    $res = $db->query('select * from user');
    var_dump($res);
});

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ £¬ÎÒÃÇÊ×ÏȽ¨ÉèÁËÒ»¸öЭ³ÌMySQL¿Í»§¶Ë £¬È»ºóʹÓÃconnect()ÒªÁìÅþÁ¬µ½MySQLЧÀÍÆ÷¡£½Ó×Å £¬ÎÒÃÇʹÓÃquery()ÒªÁìÀ´Ö´ÐÐÒ»ÌõÅÌÎÊÓï¾ä £¬²¢½«Ð§¹û·ÅÈë$res±äÁ¿ÖС£ÕâÑù £¬ÎÒÃǾͿÉÒÔÔÚЭ³ÌÖÐʵÏÖ¸ßЧµÄÊý¾ÝÅÌÎÊÁË¡£

2¡¢Ê¹ÓÃЭ³ÌRedis¿Í»§¶Ë

ÔÚʹÓÃЭ³ÌRedis¿Í»§¶Ë֮ǰ £¬ÎÒÃÇͬÑùÐèÒªÏÈ×°ÖÃswooleÀ©Õ¹ÖеÄredisÄ£¿é £¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°Öãº

pecl install swoole_redis

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³ÉÖ®ºó £¬ÎÒÃǾͿÉÒÔÔÚЭ³ÌÖÐʹÓÃЭ³ÌRedis¿Í»§¶ËÁË¡£ÏÂÃæÊÇÒ»¸öʹÓÃЭ³ÌRedis¿Í»§¶Ë´æÈ¡Êý¾ÝµÄÀý×Ó£º

Coun(function(){
    $redis = new SwooleCoroutineRedis();
    $redis->connect('127.0.0.1', 6379);
    $redis->set('name', 'swoole');
    $name = $redis->get('name');
    var_dump($name);
});

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ £¬ÎÒÃÇÊ×ÏȽ¨ÉèÁËÒ»¸öЭ³ÌRedis¿Í»§¶Ë £¬È»ºóʹÓÃconnect()ÒªÁìÅþÁ¬µ½RedisЧÀÍÆ÷¡£½Ó×Å £¬ÎÒÃÇʹÓÃset()ÒªÁ콫һ¸ö¼üÖµ¶Ô´æÈëRedisÖÐ £¬ÔÙʹÓÃget()ÒªÁìÀ´»ñÈ¡¼üÖµ¶ÔµÄÖµ¡£ÕâÑù £¬ÎÒÃǾͿÉÒÔÔÚЭ³ÌÖÐʵÏÖ¸ßЧµÄ´æÈ¡Êý¾ÝÁË¡£

Èý¡¢×ܽá

ÔÚ±¾ÎÄÖÐ £¬ÎÒÃÇÏÈÈÝÁËÔõÑùʹÓÃSwooleЭ³ÌÀ´ÊµÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷¡£Í¨¹ýʹÓÃЭ³ÌMySQL¿Í»§¶ËºÍЭ³ÌRedis¿Í»§¶Ë £¬ÎÒÃÇ¿ÉÒÔÔÚÒ»¸öÏß³ÌÖÐʵÏÖ¸ßЧµÄÊý¾ÝÅÌÎʺͲÙ×÷¡£Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤ £¬Ê¹ÓÃSwooleЭ³ÌÀ´ÊµÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷ÒѾ­³ÉΪЧÀÍÆ÷¿ª·¢ÕßµÄÒ»¸öÖ÷ÒªÊÖÒÕ¡£ÎÒÃÇÏ£Íû±¾ÎÄÄܹ»¶Ô¸÷ÈËÓÐËù×ÊÖú £¬×ÊÖú¸÷È˸üºÃµØÓ¦¶Ô²¢·¢Êý¾Ý²Ù×÷µÄÎÊÌâ¡£

ÒÔÉϾÍÊÇSwoole½ø½×£ºÔõÑùʹÓÃЭ³ÌʵÏÖ¸ßЧ²¢·¢Êý¾Ý²Ù×÷µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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