mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * @link http://www.yiiframework.com/
 | 
						|
 * @copyright Copyright (c) 2008 Yii Software LLC
 | 
						|
 * @license http://www.yiiframework.com/license/
 | 
						|
 */
 | 
						|
 | 
						|
namespace yii\mutex;
 | 
						|
 | 
						|
use Yii;
 | 
						|
use yii\db\Connection;
 | 
						|
use yii\base\InvalidConfigException;
 | 
						|
use yii\di\Instance;
 | 
						|
 | 
						|
/**
 | 
						|
 * DbMutex is the base class for classes, which relies on database while implementing mutex "lock" mechanism.
 | 
						|
 *
 | 
						|
 * @see Mutex
 | 
						|
 *
 | 
						|
 * @author resurtm <resurtm@gmail.com>
 | 
						|
 * @since 2.0
 | 
						|
 */
 | 
						|
abstract class DbMutex extends Mutex
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @var Connection|string the DB connection object or the application component ID of the DB connection.
 | 
						|
     * After the Mutex object is created, if you want to change this property, you should only assign
 | 
						|
     * it with a DB connection object.
 | 
						|
     */
 | 
						|
    public $db = 'db';
 | 
						|
 | 
						|
    /**
 | 
						|
     * Initializes generic database table based mutex implementation.
 | 
						|
     * @throws InvalidConfigException if [[db]] is invalid.
 | 
						|
     */
 | 
						|
    public function init()
 | 
						|
    {
 | 
						|
        parent::init();
 | 
						|
        $this->db = Instance::ensure($this->db, Connection::className());
 | 
						|
    }
 | 
						|
}
 |