<?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($Jo7ME, $k8RFa) { return CacheUtil::rememberForever("LazyValue.{$Jo7ME}", function () use($k8RFa) { return md5(serialize($k8RFa())); }); } public static function notifyChange($Jo7ME) { CacheUtil::forget("LazyValue.{$Jo7ME}"); } public static function status(&$gbkxa) { foreach ($gbkxa as $PSYn9) { if (null === $PSYn9) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($gbkxa) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($gbkxa), 'value' => $gbkxa)); } public static function get($Jo7ME, $KJ3xr, $rnyWQ, $Vuajy = 86400) { goto MR6_O; TLOrC: return @json_decode($UuYsu['value'], true); goto R35bv; mNAYR: if (empty($UuYsu)) { goto nv3xj; sLz8g: return null; goto HFTkO; nv3xj: ModelUtil::insert('lazy_value', array('key' => $Jo7ME, 'param' => json_encode($KJ3xr), 'expire' => time() + $rnyWQ, 'lifeExpire' => time() + $Vuajy, 'cacheSeconds' => $rnyWQ, 'value' => null)); goto Zcgbn; Zcgbn: LazyValueJob::create($Jo7ME, $KJ3xr, $rnyWQ); goto sLz8g; HFTkO: } goto qBLYa; qBLYa: if ($UuYsu['expire'] < time()) { ModelUtil::update('lazy_value', $J3gqh, array('expire' => time() + $rnyWQ, 'lifeExpire' => time() + $Vuajy, 'cacheSeconds' => $rnyWQ)); LazyValueJob::createRefresh($Jo7ME, $KJ3xr, $rnyWQ); } goto TLOrC; ZQn8t: $UuYsu = ModelUtil::get('lazy_value', $J3gqh); goto mNAYR; MR6_O: $J3gqh = array('key' => $Jo7ME, 'param' => json_encode($KJ3xr)); goto ZQn8t; R35bv: } public static function watch() { goto S3zDB; SPB6p: foreach ($oRX0Q as $UHOKU) { LazyValueJob::createRefresh($UHOKU->key, @json_decode($UHOKU->param, true), $UHOKU->cacheSeconds); } goto niyND; GLb5G: $oRX0Q = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto SPB6p; S3zDB: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto GLb5G; niyND: } }