- 释放代码后,请重新加载或重新启动swoole_http_server。因为swoole_http_server启动后,Laravel程序将保留在内存中。这就是swoole_http_server具有高性能的原因。
- 切勿使用dd(),exit()或die()功能打印您的调试消息。它将意外终止您的Swoole。
- global并且static变量需要手动销毁(重置)。
- 将元素无限追加到静态/全局变量将导致内存泄漏。
- flush()/ ob_flush()/ ob_end_flush()/ ob_implicit_flush()不会在swoole响应支持。
- 不要在响应中使用header()/ setcookie()/ http_response_code(),而仅在照亮响应中返回。
- 请求标头不能超过8 KB。这受Swoole限制。
- 默认情况下,Swoole中10 MB限制了POST数据/文件的最大大小package_max_length。
- 您应该具有有关多进程编程和Swoole的基本知识。如果您仍然使用传统的php概念编写代码,则您的应用可能会出现意外错误。
队列驱动
在 queue.php
中添加 swoole 驱动
'swoole' => [
'driver' => 'swoole',
]
swoole 表
'tables' => [
// 表名
'table_name' => [
// 表行数
'size' => 1024,
// 对于int和float类型,列名、列类型和列类型大小是可选的
// TYPE_INT: 1,2,4,8
// TYPE_FLOAT: 8
// TYPE_STRING: 2的 n 次方
'columns' => [
['name' => 'column_name1', 'type' => Table::TYPE_INT],
['name' => 'column_name2', 'type' => Table::TYPE_STRING, 'size' => 1024],
]
],
]
swoole 表用法
<?php
use SwooleTW\Http\Table\Facades\SwooleTable as Table;
class Foo
{
// get a table by its name
$table = Table::get('table_name');
// update a row of the table by key
$table->set('key', ['col_name' => 'value']);
// get a row of the table by key
$table->get('key', 'col_name');
// delete a row of the table by key
$table->del('key');
// check if a row is existed by key
$table->exist('key');
// count the rows in the table
$table->count();
}