lstrojny / procrastinator
在请求中尽可能晚地执行事情。不要让用户等待
0.8.0
2017-02-26 22:46 UTC
Requires
- php: >=5.3.0
- doctrine/orm: 2.*
Requires (Dev)
- lstrojny/phpunit-function-mocker: dev-master
- phpunit/phpunit: ~6
This package is auto-updated.
Last update: 2024-09-16 05:53:27 UTC
README
几个类,帮助您延迟执行复杂任务(如发送邮件)。
使用fastcgi_finish_request()在执行任务前完成请求的示例
<?php $procrastinator = new \Procrastinator\DeferralManager( new \Procrastinator\Scheduler\OnRegisterShutdownScheduler(), new \Procrastinator\Executor\Decorator\PhpFpmExecutorDecorator( new \Procrastinator\Executor\SingleThreadExecutor() ) ); // The rough way $procrastinator->register( new \Procrastinator\Deferred\CallbackDeferred( 'some name', function() {sleep(10);} ) ); // Or use the more convenient builder interface $procrastinator->register( $procrastinator ->newDeferred() ->name('some other name') ->call(function() {sleep(10);} ->build() ); $procrastinator->schedule();