-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateTask.php
More file actions
32 lines (17 loc) · 1008 Bytes
/
CreateTask.php
File metadata and controls
32 lines (17 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require('../no-composer-require.php');
require('autoload-mynamespace.php');
use iry\queue\Client;
use MyNamespace\Queue2Config\SettingTest2;
//--------------------
$client = new Client(SettingTest2::class);
$client->create('test_name',['test_arg_1'=>'1','test_arg_2'=>'2']);//创建异步任务
$client->create('test_name',['test_arg_1'=>'1','test_arg_2'=>'2'],'',time()+3600);//创建一个延时1小时的异步任务
$client->create('test_name',['test_arg_1'=>'1','test_arg_2'=>'2'],'',time()+3600,false);//关闭重复检查(允许重复添加)
//--------------------
//m[main的简写]会自动缓存示例 可以轻松实现 单例模式调用
//该方法 会自动执行 “new Client” 并且自动缓存实例
$client = Client::m(SettingTest2::class);
//下面两个方法等效
$client->create('test_name',['test_arg_1'=>'1','test_arg_2'=>'2'],'',time()+3600);
$client->delayedExec('test_name',['test_arg_1'=>'1','test_arg_2'=>'2'],'',3600);