https://github.com/swokit/memory
memory table for swoole
https://github.com/swokit/memory
memory-table swoole swoole-table
Last synced: about 1 year ago
JSON representation
memory table for swoole
- Host: GitHub
- URL: https://github.com/swokit/memory
- Owner: swokit
- License: mit
- Created: 2018-05-06T05:24:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-20T02:17:09.000Z (over 7 years ago)
- Last Synced: 2025-03-24T09:11:28.780Z (about 1 year ago)
- Topics: memory-table, swoole, swoole-table
- Language: PHP
- Size: 11.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# memory for swoole
swoole memory 工具的一些封裝
> 快速方便的使用swoole server [swokit/server](https://github.com/swokit/server)
主要包含有:
- 一个语言管理类
- 内存表使用封装(除了基本的 get/set/del 增加了数据导出和恢复,简单的字段搜索)
- 当使用多个内存表时,可以使用 `MemoryDB` 来管理
- 一个使用swoole table的缓存类实现,PSR 16
## install
```bash
composer require swokit/memory
```
## 内存表
* Table使用共享内存来保存数据,在创建子进程前,务必要执行 `Table->create()`
* swoole_server中使用Table,Table->create() 必须在 `swoole_server->start()` 前执行
```php
$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();
```
使用:
```php
$userTable->save('key', [
'username' => 'tom',
'password' => 'string',
]);
$row = $userTable->get('key');
$password = $userTable->get('key', 'password');
```
## license
MIT