基于swoole的极简框架-1.4.1

one 1.4.1版本更新:
优化
优化uuid生成规则
修复
缓存驱动为file时 notice错误
增加
允许在模型自己创建查询构造器链式调用
class Article extends Model
{
CONST TABLE = ‘articles’;

public function week()
{
return $this->where(‘create_at’, ‘>’, strtotime(‘-1 week’));
}

/**
* 根据点赞排序
*/
public function orderByLikeCount()
{
return $this->orderBy(‘like_count’, ‘desc’);
}

}

// 获取周排行榜 按照点赞数量
Article::column([‘id’,’title’])->where(‘create_at’, ‘>’, strtotime(‘-1 week’))->orderBy(‘like_count’, ‘desc’)->limit(10)->findAll();

// 通过自己创建的查询构造器
Article::column([‘id’,’title’])->week()->orderByLikeCount()->limit(10)->findAll();

添加rpc 方法 支持数组

// 添加方法`method1`,`method2` 供远程客户端调用

RpcServer::add(Abc::class,’method1′);
RpcServer::add(Abc::class,’method2′);

// 现在可以这么写
RpcServer::add(Abc::class,[‘method1′,’method2’]);

队列固定长度
$global_data = new \App\GlobalData\Client();
// 设置队为固定长度
$global_data->setQueueLimit(3);
$arr = [1, 2, 3, 4, 5];
foreach ($arr as $i) {
$global_data->push(‘abc’, $i);
}

while (1) {
$ret = $global_data->pop(‘abc’);
if ($ret !== null) {
echo $ret . PHP_EOL;
} else {
break;
}
}

//以上输出
//3
//4
//5

//删除固定长度限制
$global_data->delQueueLimit(‘abc’);

github: https://github.com/lizhichao/one码云: https://gitee.com/vicself/one

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理