Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-micro
Commits
3aa6085c
Commit
3aa6085c
authored
Feb 12, 2022
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步协程与异步日志批处理
parent
89469586
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
README.md
README.md
+8
-8
No files found.
README.md
View file @
3aa6085c
...
...
@@ -159,7 +159,7 @@ info(1);
用法:
继承
\M
eibuyu
\M
icro
\M
odel
\B
aseModel 的模型:
`
``
`
```
class LogTrace extends BaseModel
{
...
...
@@ -183,17 +183,17 @@ info(1);
];
}
`
``
`
```
得到基于主键或唯一索引作为条件的俩个批处理方法:
`
```
```
//批量更新,、$data为二维数组,必须包含主键或唯一索引的数据
//参数二缺省为主键名,或唯一索引名
LogTrace::getModel()->batchUpdateByField($data,'request_id')
//基于ON DUPLICATE KEY UPDATE 批量更新或插入 $data 必须包含主键或唯一索引的数据
LogTrace::getModel()->batchUpdateOrCreateByUniqueKey($data);
`
```
```
### 6、基于@LogTrace()注解,实现异步日志队列服务
用法:
...
...
@@ -345,7 +345,7 @@ class SyncTraceLog extends AbstractProcess
对于耗时长,加快影响效率,可以使用写队列,消费处理。
也可以将这部分逻辑放到异步协程去处理,用法:
```
`
```
http 请求test1,调用 延迟5s的continueTest(该方法已加入AsyncCoroutine注解),
但接口马上返回结果。5s后,后台将continueTest方法逻辑执行输出到控制台或者写入日志
...
...
@@ -378,9 +378,9 @@ class SyncTraceLog extends AbstractProcess
}
```
`
```
##### 使用须知
`
```
```
1. 给某个方法加上异步协程AsyncCoroutine注解,该方法被投放到另一个协程执行,
该方法的传参尽量不要使用模型对象(等连接资源对象),如果使用模型对象投递到
另一个协程,进行更新操作,会造成数据错乱。如要使用应禁止更新等操作
...
...
@@ -389,4 +389,4 @@ class SyncTraceLog extends AbstractProcess
对异步协程执行的情况进行跟踪,但在异步协程里,第二个参数必须为true
如 LogTraceHandler::recordProcess('记录输出数据',true);
```
`
\ No newline at end of file
```
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment