swoole之内存

一、代码

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

猜你喜欢

转载自www.cnblogs.com/cshaptx4869/p/11140970.html