<?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 k0maR; k0maR: $mi91_ = new MySqlLock(config('env.DB_USERNAME'), config('env.DB_PASSWORD'), config('env.DB_HOST')); goto CJD6E; CJD6E: $uG2OS = new MutexFabric('mysql', $mi91_); goto p85lW; p85lW: self::$instance = $uG2OS; goto GzEQr; GzEQr: } return self::$instance; } public static function acquire($glP3G, $PmvMF = null) { if (self::instance()->get($glP3G)->acquireLock($PmvMF)) { return true; } return false; } public static function release($glP3G) { self::instance()->get($glP3G)->releaseLock(); } }