devcreel/command-lockable-trait
Composer 安装命令:
composer require devcreel/command-lockable-trait
包简介
Symfony console command lockable trait
README 文档
README
Symfony console command lockable trait (very simple emulation of multithreading)
Installation
Use
Add this to composer.json
{
"require": {
"devcreel/command-lockable-trait": "1.0.*-dev"
}
}
Usage
<?php namespace TestBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use DevCreel\Command\LockableTrait; class TestCommand extends ContainerAwareCommand { use LockableTrait; //count of threads private $threadsCount = 5; protected function configure() { $this->setName('test:run'); } protected function execute(InputInterface $input, OutputInterface $output) { //check for free thread if (!$this->lock()) { $output->writeln('[' . $this->getName() . '] is already running in another process.'); return 0; } //your code... //release thread $this->release(); } }
License
CommandLockableTrait is licensed under the MIT License
统计信息
- 总下载量: 59
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-15