一、代码

<?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'));

 

文档: https://wiki.swoole.com/wiki/page/p-table.html

相关文章:

  • 2022-01-20
  • 2021-06-03
  • 2021-12-10
  • 2021-06-23
  • 2021-12-15
  • 2021-11-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-06-07
  • 2021-10-06
  • 2022-01-20
相关资源
相似解决方案