<?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 aXdqV; aXdqV: $sX3cT = new MySqlLock(config('env.DB_USERNAME'), config('env.DB_PASSWORD'), config('env.DB_HOST')); goto gD4YY; gD4YY: $GmrG4 = new MutexFabric('mysql', $sX3cT); goto LcYdW; LcYdW: self::$instance = $GmrG4; goto J09eU; J09eU: } return self::$instance; } public static function acquire($sQIr6, $RPm2k = null) { if (self::instance()->get($sQIr6)->acquireLock($RPm2k)) { return true; } return false; } public static function release($sQIr6) { self::instance()->get($sQIr6)->releaseLock(); } }