<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use NinjaMutex\Lock\MySqlLock; use NinjaMutex\MutexFabric; class DBLockUtil { static $instance = null; private static function instance() { if (null === self::$instance) { goto jlmJ0; jlmJ0: $mbzGK = new MySqlLock(config('env.DB_USERNAME'), config('env.DB_PASSWORD'), config('env.DB_HOST')); goto NW5bl; NW5bl: $FYFvP = new MutexFabric('mysql', $mbzGK); goto bXQ9M; bXQ9M: self::$instance = $FYFvP; goto kZNzM; kZNzM: } return self::$instance; } public static function acquire($XggBq, $dUHzU = null) { if (self::instance()->get($XggBq)->acquireLock($dUHzU)) { return true; } return false; } public static function release($XggBq) { self::instance()->get($XggBq)->releaseLock(); } }