swokit / memory
swokit的一些内存表工具库
v1.0.1
2018-09-20 02:16 UTC
Requires
- php: >7.0.0
Suggests
- inhere/console: a lightweight php console application library.
- inhere/server: Use swoole server quickly and easily
This package is auto-updated.
Last update: 2024-09-10 05:25:59 UTC
README
对swoole内存工具的一些封装
快速方便地使用swoole server swokit/server
主要包含有:
- 一个语言管理类
- 内存表使用封装(除了基本的 get/set/del 增加了数据导出和恢复,简单的字段搜索)
- 当使用多个内存表时,可以使用
MemoryDB
来管理 - 一个使用swoole table的缓存类实现,PSR 16
安装
composer require swokit/memory
内存表
- Table使用共享内存来保存数据,在创建子进程前,务必执行
Table->create()
- 在swoole_server中使用Table,Table->create() 必须在
swoole_server->start()
前执行
$userTable = new MemoryTable('user', 1024); $userTable->setColumns([ 'id' => [Table::TYPE_INT, 10], 'username' => [Table::TYPE_STRING, 32], 'password' => [Table::TYPE_STRING, 64], ]); // create it $userTable->create();
使用:
$userTable->save('key', [ 'username' => 'tom', 'password' => 'string', ]); $row = $userTable->get('key'); $password = $userTable->get('key', 'password');
许可
MIT