<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\LazyValue; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use ModStart\Core\Util\SerializeUtil; use Module\Vendor\Util\CacheUtil; class LazyValueUtil { public static function hash($sFwJk, $eIeJB) { return CacheUtil::rememberForever("LazyValue.{$sFwJk}", function () use($eIeJB) { return md5(serialize($eIeJB())); }); } public static function notifyChange($sFwJk) { CacheUtil::forget("LazyValue.{$sFwJk}"); } public static function status(&$jkY57) { foreach ($jkY57 as $Iim2u) { if (null === $Iim2u) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($jkY57) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($jkY57), 'value' => $jkY57)); } public static function get($sFwJk, $w6bW5, $Nh2dJ, $fsCBd = 86400) { goto c1_2c; NjalE: $r0V_P = ModelUtil::get('lazy_value', $dNpGx); goto JNj2A; PN69O: if ($r0V_P['expire'] < time()) { ModelUtil::update('lazy_value', $dNpGx, array('expire' => time() + $Nh2dJ, 'lifeExpire' => time() + $fsCBd, 'cacheSeconds' => $Nh2dJ)); LazyValueJob::createRefresh($sFwJk, $w6bW5, $Nh2dJ); } goto r3da1; r3da1: return @json_decode($r0V_P['value'], true); goto S22Kp; JNj2A: if (empty($r0V_P)) { goto FOXUV; FOXUV: ModelUtil::insert('lazy_value', array('key' => $sFwJk, 'param' => SerializeUtil::jsonEncode($w6bW5), 'expire' => time() + $Nh2dJ, 'lifeExpire' => time() + $fsCBd, 'cacheSeconds' => $Nh2dJ, 'value' => null)); goto XMHmH; OxtAR: return null; goto nB4bC; XMHmH: LazyValueJob::create($sFwJk, $w6bW5, $Nh2dJ); goto OxtAR; nB4bC: } goto PN69O; c1_2c: $dNpGx = array('key' => $sFwJk, 'param' => SerializeUtil::jsonEncode($w6bW5)); goto NjalE; S22Kp: } public static function watch() { goto a5vjk; rRAVu: foreach ($zkVI3 as $Jd4L6) { LazyValueJob::createRefresh($Jd4L6->key, @json_decode($Jd4L6->param, true), $Jd4L6->cacheSeconds); } goto zRDsT; EA0_b: $zkVI3 = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto rRAVu; a5vjk: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto EA0_b; zRDsT: } }