Swoole 4.1.0 official release supports native Redis/PDO/MySQLi orchestration

  Asynchronous, coroutine, php, swoole

Major new features

Redis/PDO/MySQLi support

From4.1.0Version began to support the rightPHPNativeRedisPDOMySQLiThe support of coordination.

AvailableSwoole\Runtime::enableCorotuine()Blocking common synchronizationRedisPDOMySQLiAsynchronous Non-blocking with Operations Becoming Coordinated SchedulingIO

Swoole\Runtime::enableCoroutine();
 
 go(function () {
 $redis = new redis;
 $retval = $redis->connect("127.0.0.1", 6379);
 var_dump($retval, $redis->getLastError());
 var_dump($redis->get("key"));
 var_dump($redis->set("key", "value"));
 $redis->close();
 });

Concorde tracking

The new version adds two methods to track coordinated operation.

  • Coroutine::listCoroutines()It can traverse all current synergetic processes.
  • Coroutine::getBackTrace($cid)A function call stack that can obtain a certain coordination
function test1() {
 test2();
 }
 
 function test2() {
 while(true) {
 co::sleep(10);
 echo __FUNCTION__." \n";
 }
 }
 
 $cid = go(function () {
 test1();
 });
 
 go(function () use ($cid) {
 while(true) {
 echo "BackTrace[$cid]:\n-----------------------------------------------\n";
 //Return array, need self-print format
 var_dump(co::getBackTrace($cid))."\n";
 co::sleep(3);
 }
 });
BackTrace[1]:
 -----------------------------------------------
 #0  Swoole\Coroutine::sleep(10) called at [/home/htf/workspace/swoole/examples/coroutine/backtrace.php:8]
 #1  test2() called at [/home/htf/workspace/swoole/examples/coroutine/backtrace.php:3]
 #2  test1() called at [/home/htf/workspace/swoole/examples/coroutine/backtrace.php:14]

Other amendments

  • ReconstructionCo\ChannelThe underlying code of C is C++, which solves unexpected results of complex scenes and realizes high stability.
  • ReconstructionCo\Http\ClientThe underlying code of C is C++ synergetic mode, which solves the asynchronous timing problem and realizes high stability.
  • Support for use in coordination and ServerexitAt this point, the catch will be thrown\Swoole\ExitExceptionabnormal
  • Remove PCRE dependency restrictions for all iterators (table/connection/coroutine _ list)
  • Increaseopen_websocket_close_frameConfiguration, close frame can be received in onMessage event
  • AbandonedHttp\Response->gzip()Method, use insteadhttp_compressionConfiguration item. The bottom layer will automatically judge the incoming from the clientAccept-EncodingSelect the appropriate compression method and add Google BR compression support.
  • IncreaseCo\Http\Client->addData()Method, data in memory can be sent as uploaded file content
  • Solarissystem support
  • Http2 supportMAX_FRAME_SIZEFraming andMAX_HEADER_LIST_SIZEProcessing, client increaseisStreamExistThe method detects whether there is a corresponding flow
  • swoole_http_response->statusIncreasereasonParameter
  • Fix the problem of numeric overflow caused by unsigned parameters using signed values in MySQL prepare
  • Repair HTTP2′ sonRequestThere is no coordination problem in the callback.
  • Repairtasking_numUnder certain special circumstances, it becomes-1The problem of
  • Fix window-update frame construction error for HTTP2-server
  • Fix all levels of compilation warning under all PHP versions
  • Compilation errors will occur when GCC version is less than 4.8
  • Fixes memory allocation increasing due to MySQL not using parameter binding when using prepare
  • Repairing Old stream Memory Loss Leakage During HTTP2 Reconnection

Related to bottom-level development

  • Uniform file naming#970
  • Co\Http\ClientUsedcreate_objAndfree_objEnsure memory security and prevent incorrect PHP code from causing memory problems