framework/mutex/MysqlMutex.php
protected function acquireLock($name, $timeout = 0)
    {
        return $this->db->useMaster(function ($db) use ($name, $timeout) {
            /** @var \yii\db\Connection $db */
            return (bool) $db->createCommand(
                'SELECT GET_LOCK(:name, :timeout)',
                [':name' => $this->hashLockName($name), ':timeout' => $timeout]
            )->queryScalar();
        });
    }
protected function acquireLock($name, $timeout = 0)
    {
        return $this->db->useMaster(function ($db) use ($name, $timeout) {
            /** @var \yii\db\Connection $db */
            return (bool) $db->createCommand(
                'SELECT GET_LOCK(:name, :timeout)',
                [':name' => $this->hashLockName($name), ':timeout' => $timeout]
            )->queryScalar();
        });
    }
Acquires lock by given name.
@param string $name of the lock to be acquired.
@param int $timeout time (in seconds) to wait for lock to become released.
@return bool acquiring result.
@see http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_get-lock