Skip to content

njspok/yii2-mutex-behavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Code Climate

yii2-mutex-behavior

This behavior add concurrent lock on action controller. If lock acquire run same action again impossible.

Requirements

  • PHP 5.5.9 and later
  • YII2 Framework

How use

class SomeController extends Controller
{
    public function behaviors()
    {
        return [
            [
                'class' => MutexBehavior::className(),
                'mutex' => FileMutex::className(),
                'annotationMark' => '@mark-mutex',
                // 'mutexName' => string or callable
            ]
        ];
    }
        
    /**
     * This action executed in any case
     */
    public function actionWithouMutex()
    {
		// some do
    }
    
    /**
     * This action not executed if already run
     * @mark-mutex
     */
    public function actionWithMutex()
    {
		// some do
    }
}

Install

composer install

Run tests

./vendor/bin/phpunit

In the future

  • trigger event if acquire lock fail
  • configure mutex name

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages