1、代碼php
<?php // 能夠用來數據共享 // 執行完後 自動釋放 // 建立內存表 $table = new swoole_table(1024); // 內存表增長一列 $table->column('id', $table::TYPE_INT, 4); $table->column('name', $table::TYPE_STRING, 64); $table->column('age', $table::TYPE_INT, 3); $table->create(); // 設置數據 $table->set('tomInfo', ['id'=>1, 'name'=>'tom','age'=>20]); $table['jerryInfo'] = [ 'id'=>2, 'name'=>'jerry', 'age'=>20 ]; $table->incr('jerryInfo', 'age', 2); $table->decr('jerryInfo', 'age', 4); // 獲取數據 print_r($table->get('jerryInfo')); print_r($table['jerryInfo']); // 刪除數據 $table->del('tomInfo'); print_r($table->get('tomInfo'));