<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\LazyValue; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use Module\Vendor\Util\CacheUtil; class LazyValueUtil { public static function hash($UtKOH, $GdSl0) { return CacheUtil::rememberForever("LazyValue.{$UtKOH}", function () use($GdSl0) { return md5(serialize($GdSl0())); }); } public static function notifyChange($UtKOH) { CacheUtil::forget("LazyValue.{$UtKOH}"); } public static function status(&$fo71I) { foreach ($fo71I as $y2Ltn) { if (null === $y2Ltn) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($fo71I) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($fo71I), 'value' => $fo71I)); } public static function get($UtKOH, $qOrzw, $Z0Hja, $L5S5I = 86400) { goto vaTPU; HJuWM: return @json_decode($pRqvo['value'], true); goto L_f10; FtQD4: if (empty($pRqvo)) { goto djktO; CEcvd: LazyValueJob::create($UtKOH, $qOrzw, $Z0Hja); goto E1Q9R; djktO: ModelUtil::insert('lazy_value', array('key' => $UtKOH, 'param' => json_encode($qOrzw), 'expire' => time() + $Z0Hja, 'lifeExpire' => time() + $L5S5I, 'cacheSeconds' => $Z0Hja, 'value' => null)); goto CEcvd; E1Q9R: return null; goto TbQIC; TbQIC: } goto GKij6; GKij6: if ($pRqvo['expire'] < time()) { ModelUtil::update('lazy_value', $xAO9M, array('expire' => time() + $Z0Hja, 'lifeExpire' => time() + $L5S5I, 'cacheSeconds' => $Z0Hja)); LazyValueJob::createRefresh($UtKOH, $qOrzw, $Z0Hja); } goto HJuWM; OWyCj: $pRqvo = ModelUtil::get('lazy_value', $xAO9M); goto FtQD4; vaTPU: $xAO9M = array('key' => $UtKOH, 'param' => json_encode($qOrzw)); goto OWyCj; L_f10: } public static function watch() { goto U5g50; NSG6r: foreach ($oiC1v as $KfcNX) { LazyValueJob::createRefresh($KfcNX->key, @json_decode($KfcNX->param, true), $KfcNX->cacheSeconds); } goto tYLvJ; U5g50: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto B3GtV; B3GtV: $oiC1v = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto NSG6r; tYLvJ: } }