代码拉取完成,页面将自动刷新
task-schedule-php是一个php任务调度框架,开发者可以使用这个框架来设置周期任务/一次性的延时任务后期异步执行。 ##动机:
##典型的应用场景:
function helloWorld(){
echo "\n\nhello world\n\n";
return true;
}
$redisIp = '10.10.9.77';
$redisPort = '6379';
$redisTimeout = 2;
$redisClient = new \TaskSchedule\Libs\RedisWithReConnect($redisIp, $redisPort, $redisTimeout);
$scheduler = new \TaskSchedule\Core\TaskScheduler\RedisTaskSchedulerWithTransaction($redisClient);
$tasks = new \TaskSchedule\Core\Tasks\RedisTasks($redisClient);
$runner = new \TaskSchedule\Core\TaskRunner($taskResult);
$timeEvent = new \TaskSchedule\Core\TimeEvent\TimeEvent($scheduler, $tasks, $runner);
#####生产者将该任务添加到计划中。
$timeSpace = 2;
$type = \TaskSchedule\Core\Tasks\TasksInterface::RUN_REPEATED;
$func = 'helloWorld';
//注意,在add任务之前,先初始化下maxTaskId。
$timeEvent->add($timeSpace, $type, $func, $args = null);
#####消费者获取到任务并执行。
$runTimeLen = 5;
$timeEvent->loop($runTimeLen);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。