<?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 bEqSE; bEqSE: $tG_Un = new MySqlLock(config('env.DB_USERNAME'), config('env.DB_PASSWORD'), config('env.DB_HOST')); goto fRLnd; fRLnd: $ehdui = new MutexFabric('mysql', $tG_Un); goto mlswZ; mlswZ: self::$instance = $ehdui; goto sNlAm; sNlAm: } return self::$instance; } public static function acquire($rPkIY, $gtCgf = null) { if (self::instance()->get($rPkIY)->acquireLock($gtCgf)) { return true; } return false; } public static function release($rPkIY) { self::instance()->get($rPkIY)->releaseLock(); } }