{"id":1070,"date":"2025-01-19T13:51:14","date_gmt":"2025-01-19T05:51:14","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=1070"},"modified":"2025-01-19T13:51:14","modified_gmt":"2025-01-19T05:51:14","slug":"swoole-%e9%ab%98%e7%ba%a7%e7%89%b9%e6%80%a7%e8%a7%a3%e6%9e%90%ef%bc%9a%e6%8f%90%e5%8d%87-php-%e6%80%a7%e8%83%bd%e7%9a%84%e5%bc%ba%e5%a4%a7%e5%8a%9f%e8%83%bd%e4%b8%8e%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/01\/19\/swoole-%e9%ab%98%e7%ba%a7%e7%89%b9%e6%80%a7%e8%a7%a3%e6%9e%90%ef%bc%9a%e6%8f%90%e5%8d%87-php-%e6%80%a7%e8%83%bd%e7%9a%84%e5%bc%ba%e5%a4%a7%e5%8a%9f%e8%83%bd%e4%b8%8e%e6%8a%80%e5%b7%a7\/","title":{"rendered":"Swoole \u9ad8\u7ea7\u7279\u6027\u89e3\u6790\uff1a\u63d0\u5347 PHP \u6027\u80fd\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u6280\u5de7"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Swoole \u662f\u4e00\u4e2a\u5f3a\u5927\u7684 PHP \u6269\u5c55\uff0c\u4e13\u6ce8\u4e8e\u9ad8\u6027\u80fd\u3001\u9ad8\u5e76\u53d1\u7684\u7f51\u7edc\u7f16\u7a0b\uff0c\u9664\u4e86\u57fa\u7840\u7684\u7f51\u7edc\u670d\u52a1\u529f\u80fd\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u591a\u79cd\u9ad8\u7ea7\u7279\u6027\uff0c\u80fd\u591f\u8fdb\u4e00\u6b65\u63d0\u5347\u5e94\u7528\u7684\u6027\u80fd\u548c\u7075\u6d3b\u6027\u3002\u4ee5\u4e0b\u662f Swoole \u7684\u4e00\u4e9b\u9ad8\u7ea7\u7279\u6027\uff0c\u5305\u62ec <strong>\u534f\u7a0b<\/strong>\u3001<strong>\u8fdb\u7a0b\u7ba1\u7406<\/strong>\u3001<strong>\u5b9a\u65f6\u5668<\/strong>\u3001<strong>\u5f02\u6b65\u4efb\u52a1<\/strong>\u3001<strong>\u5185\u5b58\u7ba1\u7406<\/strong> \u7b49\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u534f\u7a0b (Coroutine)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u7684\u534f\u7a0b\u662f\u5176\u6700\u4e3a\u7a81\u51fa\u7684\u7279\u70b9\u4e4b\u4e00\u3002\u534f\u7a0b\u53ef\u4ee5\u8ba9\u4f60\u5728 PHP \u4e2d\u4ee5\u540c\u6b65\u7684\u65b9\u5f0f\u7f16\u5199\u5f02\u6b65\u4ee3\u7801\uff0c\u6781\u5927\u5730\u7b80\u5316\u4e86\u5e76\u53d1\u7f16\u7a0b\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1.1 <strong>\u534f\u7a0b\u57fa\u7840<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u534f\u7a0b\u901a\u8fc7 <code>Swoole\\Coroutine<\/code> \u7c7b\u63d0\u4f9b\u652f\u6301\uff0c\u5141\u8bb8\u5728\u4e00\u4e2a\u7ebf\u7a0b\u4e2d\u5b9e\u73b0\u7c7b\u4f3c\u591a\u7ebf\u7a0b\u7684\u5e76\u53d1\u6267\u884c\u3002Swoole \u534f\u7a0b\u91c7\u7528\u534f\u4f5c\u5f0f\u8c03\u5ea6\uff0c\u7a0b\u5e8f\u901a\u8fc7 <code>yield<\/code> \u548c <code>resume<\/code> \u6765\u6302\u8d77\u548c\u6062\u590d\u534f\u7a0b\u7684\u6267\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Swoole\\Coroutine\\run(function () {\n    \/\/ \u521b\u5efa\u534f\u7a0b\n    go(function () {\n        echo \"Coroutine 1\\n\";\n        Swoole\\Coroutine::sleep(1);  \/\/ \u534f\u7a0b\u4f11\u77201\u79d2\n        echo \"Coroutine 1 finished\\n\";\n    });\n\n    go(function () {\n        echo \"Coroutine 2\\n\";\n        Swoole\\Coroutine::sleep(0.5);  \/\/ \u534f\u7a0b\u4f11\u77200.5\u79d2\n        echo \"Coroutine 2 finished\\n\";\n    });\n});<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u534f\u7a0b\u8c03\u5ea6<\/strong>\uff1a\u534f\u7a0b\u7684\u8c03\u5ea6\u662f\u7531 Swoole \u5185\u90e8\u7684\u534f\u7a0b\u8c03\u5ea6\u5668\u8d1f\u8d23\u7684\u3002\u534f\u7a0b\u95f4\u901a\u8fc7 <code>sleep()<\/code>\u3001<code>wait()<\/code> \u7b49\u51fd\u6570\u5b9e\u73b0\u975e\u963b\u585e\u7b49\u5f85\u3002<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u4f18\u52bf<\/strong>\uff1a\u4e0e\u4f20\u7edf\u7684\u591a\u7ebf\u7a0b\u3001\u8fdb\u7a0b\u6a21\u578b\u76f8\u6bd4\uff0c\u534f\u7a0b\u80fd\u591f\u5728\u540c\u4e00\u4e2a\u7ebf\u7a0b\u5185\u5e76\u53d1\u6267\u884c\u5927\u91cf\u4efb\u52a1\uff0c\u907f\u514d\u4e86\u4e0a\u4e0b\u6587\u5207\u6362\u548c\u5185\u5b58\u6d88\u8017\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">1.2 <strong>\u534f\u7a0b\u4e0e\u6570\u636e\u5e93\/IO<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u534f\u7a0b\u8fd8\u53ef\u4ee5\u4e0e MySQL\u3001Redis \u7b49\u670d\u52a1\u8fdb\u884c\u9ad8\u6548\u96c6\u6210\uff0c\u63d0\u4f9b\u5f02\u6b65\u4e14\u4e0d\u963b\u585e\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Swoole\\Coroutine\\run(function () {\n    $mysql = new Swoole\\Coroutine\\Mysql();\n    $result = $mysql-&gt;query(\"SELECT * FROM users\");\n    var_dump($result);\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7 Swoole \u534f\u7a0b\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u534f\u7a0b\u65b9\u5f0f\u6267\u884c MySQL\u3001Redis \u7b49\u5f02\u6b65 I\/O \u64cd\u4f5c\uff0c\u800c\u4e0d\u9700\u8981\u624b\u52a8\u7ba1\u7406\u56de\u8c03\u51fd\u6570\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u8fdb\u7a0b\u7ba1\u7406<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8fdb\u7a0b\u7ba1\u7406\u529f\u80fd\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u7ba1\u7406\u5b50\u8fdb\u7a0b\u3001\u8fdb\u884c\u8fdb\u7a0b\u95f4\u901a\u4fe1\uff08IPC\uff09\u7b49\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.1 <strong>\u8fdb\u7a0b\u6c60 (Process Pool)<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fdb\u7a0b\u6c60\u662f Swoole \u63d0\u4f9b\u7684\u4e00\u4e2a\u529f\u80fd\uff0c\u5b83\u80fd\u591f\u9ad8\u6548\u5730\u7ba1\u7406\u591a\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u907f\u514d\u4e86\u9891\u7e41\u521b\u5efa\u548c\u9500\u6bc1\u8fdb\u7a0b\u7684\u6027\u80fd\u5f00\u9500\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$pool = new Swoole\\Process\\Pool(4);  \/\/ \u521b\u5efa\u4e00\u4e2a\u8fdb\u7a0b\u6c60\uff0c\u6700\u591a 4 \u4e2a\u5b50\u8fdb\u7a0b\n\n$pool-&gt;on(\"WorkerStart\", function($pool, $workerId) {\n    echo \"Worker {$workerId} started\\n\";\n});\n\n$pool-&gt;start();<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8fdb\u7a0b\u6c60<\/strong>\uff1aSwoole \u63d0\u4f9b\u7684\u8fdb\u7a0b\u6c60\u80fd\u521b\u5efa\u591a\u4e2a\u5b50\u8fdb\u7a0b\u6765\u5904\u7406\u4efb\u52a1\uff0c\u9002\u7528\u4e8e\u9ad8\u5e76\u53d1\u7684\u8ba1\u7b97\u5bc6\u96c6\u578b\u4efb\u52a1\u3002<\/li>\n\n\n\n<li><strong>\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/strong>\uff1a\u901a\u8fc7 <code>Swoole\\Process<\/code> \u7c7b\u53ef\u4ee5\u5728\u8fdb\u7a0b\u4e4b\u95f4\u8fdb\u884c\u6d88\u606f\u4f20\u9012\u548c\u540c\u6b65\uff0c\u652f\u6301 <strong>\u7ba1\u9053<\/strong> \u548c <strong>\u4fe1\u53f7<\/strong> \u7b49\u673a\u5236\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.2 <strong>\u8fdb\u7a0b\u63a7\u5236<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7 <code>Swoole\\Process<\/code> \u7c7b\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u5b50\u8fdb\u7a0b\u3001\u7ba1\u7406\u8fdb\u7a0b\u3001\u4e0e\u8fdb\u7a0b\u8fdb\u884c\u901a\u4fe1\u3001\u7b49\u5f85\u8fdb\u7a0b\u5b8c\u6210\u7b49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$process = new Swoole\\Process(function($process) {\n    echo \"Subprocess started\\n\";\n    $process-&gt;write(\"Hello from child process!\");\n}, false, true);\n\n$process-&gt;start();\necho $process-&gt;read();  \/\/ \u8bfb\u53d6\u5b50\u8fdb\u7a0b\u53d1\u9001\u7684\u6570\u636e<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8fdb\u7a0b\u7ba1\u7406<\/strong>\uff1a\u53ef\u4ee5\u63a7\u5236\u8fdb\u7a0b\u7684\u542f\u52a8\u3001\u9000\u51fa\u3001\u91cd\u542f\u7b49\u64cd\u4f5c\u3002<\/li>\n\n\n\n<li><strong>IPC\uff08\u8fdb\u7a0b\u95f4\u901a\u4fe1\uff09<\/strong>\uff1a\u652f\u6301\u901a\u8fc7\u7ba1\u9053\u3001\u4fe1\u53f7\u3001\u5171\u4eab\u5185\u5b58\u7b49\u65b9\u5f0f\u8fdb\u884c\u8fdb\u7a0b\u95f4\u901a\u4fe1\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>\u5b9a\u65f6\u5668 (Timer)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u5b9a\u65f6\u5668\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u540e\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c\uff0c\u652f\u6301 <strong>\u5355\u6b21\u5b9a\u65f6\u5668<\/strong> \u548c <strong>\u5faa\u73af\u5b9a\u65f6\u5668<\/strong>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.1 <strong>\u5b9a\u65f6\u5668\u4f7f\u7528<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>Swoole\\Timer::tick(1000, function() {\n    echo \"This will run every 1 second.\\n\";\n});\n\nSwoole\\Timer::after(2000, function() {\n    echo \"This will run after 2 seconds.\\n\";\n});<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>tick<\/code> \u5b9a\u65f6\u5668<\/strong>\uff1a\u6bcf\u9694\u6307\u5b9a\u7684\u65f6\u95f4\uff08\u6beb\u79d2\uff09\u6267\u884c\u4e00\u6b21\u56de\u8c03\u51fd\u6570\uff0c\u9002\u5408\u7528\u4e8e\u5b9a\u65f6\u4efb\u52a1\u3002<\/li>\n\n\n\n<li><strong><code>after<\/code> \u5b9a\u65f6\u5668<\/strong>\uff1a\u5ef6\u8fdf\u6307\u5b9a\u65f6\u95f4\u540e\u6267\u884c\u56de\u8c03\u51fd\u6570\uff0c\u9002\u7528\u4e8e\u4e00\u6b21\u6027\u5b9a\u65f6\u4efb\u52a1\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3.2 <strong>\u5b9a\u65f6\u5668\u9ad8\u7ea7\u7528\u6cd5<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b9a\u65f6\u5668\u53ef\u4ee5\u914d\u5408\u534f\u7a0b\u4f7f\u7528\u6765\u8fdb\u884c\u590d\u6742\u7684\u5b9a\u65f6\u4efb\u52a1\u8c03\u5ea6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Swoole\\Coroutine\\run(function() {\n    Swoole\\Timer::tick(1000, function() {\n        echo \"Every second\\n\";\n    });\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u5f02\u6b65\u4efb\u52a1 (Async Task)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u652f\u6301\u5f02\u6b65\u4efb\u52a1\u7684\u7ba1\u7406\uff0c\u80fd\u591f\u5c06\u8017\u65f6\u7684\u64cd\u4f5c\u5f02\u6b65\u5316\uff0c\u907f\u514d\u963b\u585e\u4e3b\u7ebf\u7a0b\u3002\u5e38\u7528\u4e8e\u5904\u7406\u6587\u4ef6\u4e0a\u4f20\u3001\u957f\u65f6\u95f4\u7684\u8ba1\u7b97\u4efb\u52a1\u7b49\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4.1 <strong>\u5f02\u6b65\u4efb\u52a1<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>Swoole\\Coroutine\\run(function () {\n    $result = Swoole\\Coroutine::async(function () {\n        return longRunningTask();\n    });\n    echo \"Task result: {$result}\\n\";\n});\n\nfunction longRunningTask() {\n    Swoole\\Coroutine::sleep(2);\n    return \"Completed!\";\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u534f\u7a0b\u5f02\u6b65<\/strong>\uff1a\u5f02\u6b65\u4efb\u52a1\u901a\u5e38\u901a\u8fc7\u534f\u7a0b\u6765\u5b9e\u73b0\uff0c\u4f7f\u7528 <code>Swoole\\Coroutine::async()<\/code> \u6765\u5904\u7406\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4efb\u52a1\uff0c\u5e76\u80fd\u5728\u4e0d\u963b\u585e\u4e3b\u8fdb\u7a0b\u7684\u60c5\u51b5\u4e0b\u83b7\u5f97\u7ed3\u679c\u3002<\/li>\n\n\n\n<li><strong>Task \u8fdb\u7a0b<\/strong>\uff1a\u5728 Swoole \u7684 <strong>TaskWorker<\/strong> \u6a21\u5f0f\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>task()<\/code> \u548c <code>finish()<\/code> \u8fdb\u884c\u4efb\u52a1\u6d3e\u53d1\u548c\u7ed3\u679c\u56de\u8c03\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>\u5171\u4eab\u5185\u5b58\u4e0e\u8868<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u63d0\u4f9b\u4e86 <strong>\u5171\u4eab\u5185\u5b58<\/strong> \u548c <strong>\u5171\u4eab\u8868<\/strong> \u7684\u529f\u80fd\uff0c\u7528\u4e8e\u8fdb\u7a0b\u95f4\u5171\u4eab\u6570\u636e\uff0c\u652f\u6301\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\u548c\u591a\u8fdb\u7a0b\/\u534f\u7a0b\u4e4b\u95f4\u7684\u901a\u4fe1\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">5.1 <strong>\u5171\u4eab\u5185\u5b58<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>$memory = new Swoole\\Memory(1024);  \/\/ \u5206\u914d 1024 \u5b57\u8282\u7684\u5171\u4eab\u5185\u5b58\n$memory-&gt;write(0, \"Hello, Swoole\");\necho $memory-&gt;read(0, 5);  \/\/ \u8f93\u51fa \"Hello\"<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5171\u4eab\u5185\u5b58<\/strong>\uff1a\u901a\u8fc7 <code>Swoole\\Memory<\/code>\uff0c\u4f60\u53ef\u4ee5\u4e3a\u4e0d\u540c\u7684\u8fdb\u7a0b\u6216\u534f\u7a0b\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u8fdb\u884c\u9ad8\u6548\u7684\u6570\u636e\u4ea4\u6362\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5.2 <strong>\u5171\u4eab\u8868<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>$table = new Swoole\\Table(1024);  \/\/ \u521b\u5efa\u4e00\u4e2a\u5171\u4eab\u8868\n$table-&gt;column('id', Swoole\\Table::TYPE_INT, 4);\n$table-&gt;create();\n\n\/\/ \u8bbe\u7f6e\u6570\u636e\n$table-&gt;set(1, &#91;'id' =&gt; 1, 'value' =&gt; 'test']);\n\n\/\/ \u83b7\u53d6\u6570\u636e\n$data = $table-&gt;get(1);\necho $data&#91;'value'];  \/\/ \u8f93\u51fa \"test\"<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5171\u4eab\u8868<\/strong>\uff1a\u9002\u5408\u5b58\u50a8\u4e00\u4e9b\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u7ed3\u6784\uff08\u5982\u8ba1\u6570\u5668\u3001\u72b6\u6001\u6807\u8bb0\u7b49\uff09\uff0c\u5e76\u4e14\u652f\u6301\u5728\u591a\u4e2a\u8fdb\u7a0b\u6216\u534f\u7a0b\u4e4b\u95f4\u5171\u4eab\u548c\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\u4e0e\u5bf9\u8c61\u6c60<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u63d0\u4f9b\u4e86\u5185\u5b58\u6c60\u548c\u5bf9\u8c61\u6c60\u7684\u652f\u6301\uff0c\u80fd\u591f\u51cf\u5c11\u9891\u7e41\u7684\u5185\u5b58\u5206\u914d\u548c\u56de\u6536\uff0c\u63d0\u9ad8\u5e94\u7528\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">6.1 <strong>\u5bf9\u8c61\u6c60<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u7684\u5bf9\u8c61\u6c60\u53ef\u4ee5\u5b58\u50a8\u548c\u590d\u7528\u5bf9\u8c61\uff0c\u907f\u514d\u4e86\u9891\u7e41\u521b\u5efa\u548c\u9500\u6bc1\u5bf9\u8c61\u5e26\u6765\u7684\u6027\u80fd\u5f00\u9500\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$pool = new Swoole\\Pool(10);  \/\/ \u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u6c60\n$pool-&gt;get();  \/\/ \u83b7\u53d6\u5bf9\u8c61\n$pool-&gt;put($object);  \/\/ \u5c06\u5bf9\u8c61\u653e\u56de\u6c60\u4e2d<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5bf9\u8c61\u6c60<\/strong>\uff1a\u9002\u7528\u4e8e\u9891\u7e41\u4f7f\u7528\u7684\u5bf9\u8c61\uff08\u5982\u6570\u636e\u5e93\u8fde\u63a5\u3001\u7f51\u7edc\u8fde\u63a5\u7b49\uff09\uff0c\u51cf\u5c11\u4e86\u5bf9\u8c61\u521b\u5efa\u7684\u6210\u672c\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">7. <strong>\u603b\u7ed3<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Swoole \u63d0\u4f9b\u4e86\u591a\u79cd\u9ad8\u7ea7\u7279\u6027\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u6027\u80fd\u3001\u53ef\u6269\u5c55\u7684\u7f51\u7edc\u5e94\u7528\u3002\u901a\u8fc7\u534f\u7a0b\u3001\u8fdb\u7a0b\u6c60\u3001\u5b9a\u65f6\u5668\u3001\u5f02\u6b65\u4efb\u52a1\u548c\u5185\u5b58\u7ba1\u7406\u7b49\u7279\u6027\uff0cSwoole \u5728\u5904\u7406\u9ad8\u5e76\u53d1\u548c\u9ad8\u8d1f\u8f7d\u7684\u573a\u666f\u4e2d\u8868\u73b0\u5f97\u975e\u5e38\u9ad8\u6548\u3002\u65e0\u8bba\u662f Web \u670d\u52a1\u3001\u5b9e\u65f6\u901a\u8baf\u3001\u8fd8\u662f\u5927\u6570\u636e\u5904\u7406\uff0cSwoole \u90fd\u80fd\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u5f3a\u6709\u529b\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swoole \u662f\u4e00\u4e2a\u5f3a\u5927\u7684 PHP \u6269\u5c55\uff0c\u4e13\u6ce8\u4e8e\u9ad8\u6027\u80fd\u3001\u9ad8\u5e76\u53d1\u7684\u7f51\u7edc\u7f16\u7a0b\uff0c\u9664\u4e86\u57fa\u7840\u7684\u7f51\u7edc\u670d\u52a1\u529f\u80fd\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u591a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-1070","post","type-post","status-publish","format-standard","hentry","category-swoole"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=1070"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1071,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1070\/revisions\/1071"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}