t-kanstantsin/yii2-action-lock-behavior
Composer 安装命令:
composer require t-kanstantsin/yii2-action-lock-behavior
包简介
Allow run only one action instance at once
关键字:
README 文档
README
Yii widget
Basic
Behavior allow deny multiple runs of same console application action (e.g. long time executing task initiated with cron) using yii\mutex\* package.
Lock source should be chosen carefully noting following:
-
yii\mutex\FileMutexsimple but can be used only with one docker container instance because its not possible determine if process still running or ended in another container. Requires only writable directory -
yii\mutex\DbMutexrequires db connection. May be used only with single database instance.
Example
Using mutex from global config:
public function behaviors(): array { return [ 'pid' => ActionLockBehavior::class, ]; }
Define mutex on-the-fly:
public function behaviors(): array { return [ 'pid' => [ 'class' => ActionLockBehavior::class, 'mutex' => [ 'class' => FileMutex::class, 'mutexPath' => \Yii::getAlias('@runtime/pid'), ], ], ]; }
统计信息
- 总下载量: 387
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-07-08