<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\LazyValue; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use Module\Vendor\Cache\CacheUtil; class LazyValueUtil { public static function hash($bM44E, $Z5ICb) { return CacheUtil::rememberForever("LazyValue.{$bM44E}", function () use($Z5ICb) { return md5(serialize($Z5ICb())); }); } public static function notifyChange($bM44E) { CacheUtil::forget("LazyValue.{$bM44E}"); } public static function status(&$XVADv) { foreach ($XVADv as $vuqB0) { if (null === $vuqB0) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($XVADv) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($XVADv), 'value' => $XVADv)); } public static function get($bM44E, $OzAEo, $ZXYtd, $i8IDx = 86400) { goto U18nl; ibGmq: $A73fM = ModelUtil::get('lazy_value', $mC9VI); goto SHuWP; U18nl: $mC9VI = array('key' => $bM44E, 'param' => json_encode($OzAEo)); goto ibGmq; Tnqhq: return @json_decode($A73fM['value'], true); goto hppIu; SFQ_U: if ($A73fM['expire'] < time()) { ModelUtil::update('lazy_value', $mC9VI, array('expire' => time() + $ZXYtd, 'lifeExpire' => time() + $i8IDx, 'cacheSeconds' => $ZXYtd)); LazyValueJob::createRefresh($bM44E, $OzAEo, $ZXYtd); } goto Tnqhq; SHuWP: if (empty($A73fM)) { goto RaRgw; JgBy7: return null; goto gt5Ns; hcO8Q: LazyValueJob::create($bM44E, $OzAEo, $ZXYtd); goto JgBy7; RaRgw: ModelUtil::insert('lazy_value', array('key' => $bM44E, 'param' => json_encode($OzAEo), 'expire' => time() + $ZXYtd, 'lifeExpire' => time() + $i8IDx, 'cacheSeconds' => $ZXYtd, 'value' => null)); goto hcO8Q; gt5Ns: } goto SFQ_U; hppIu: } public static function watch() { goto w2Lx8; YSRZv: $sbhfQ = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto ocAlb; w2Lx8: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto YSRZv; ocAlb: foreach ($sbhfQ as $zQeTy) { LazyValueJob::createRefresh($zQeTy->key, @json_decode($zQeTy->param, true), $zQeTy->cacheSeconds); } goto BhXpC; BhXpC: } }