鍍金池/ 問答/PHP/ swoole_table怎么替代redis當(dāng)共享緩存使用

swoole_table怎么替代redis當(dāng)共享緩存使用

我看了下,要先建立一個swoole_server,然后把swoole_table綁定在上面

感覺比redis麻煩

回答
編輯回答
膽怯

建立好內(nèi)存表即可,不需要建立一個server:

//用戶信息表
$userTable = new swoole_table(1024);
$userTable->column('cmd', swoole_table::TYPE_STRING, 64);
$userTable->column('userId', swoole_table::TYPE_INT, 64);
$userTable->column('room', swoole_table::TYPE_INT, 64);
$userTable->column('group', swoole_table::TYPE_INT, 4);
$userTable->column('userName', swoole_table::TYPE_STRING, 64);
$userTable->column('headImg', swoole_table::TYPE_STRING, 128);
$userTable->column('clientId', swoole_table::TYPE_INT, 4);
$userTable->column('type', swoole_table::TYPE_INT, 4);
$userTable->create();

這就$userTable就可以使用了

2018年9月4日 07:36