<?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($PeAfP, $TIlpS) { return CacheUtil::rememberForever("LazyValue.{$PeAfP}", function () use($TIlpS) { return md5(serialize($TIlpS())); }); } public static function notifyChange($PeAfP) { CacheUtil::forget("LazyValue.{$PeAfP}"); } public static function status(&$DiI0O) { foreach ($DiI0O as $SxG_W) { if (null === $SxG_W) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($DiI0O) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($DiI0O), 'value' => $DiI0O)); } public static function get($PeAfP, $FRVtF, $tYiXs, $uy395 = 86400) { goto CcE_o; A9qf1: return @json_decode($BSMxd['value'], true); goto ysRDO; Jg5BU: if ($BSMxd['expire'] < time()) { ModelUtil::update('lazy_value', $l970E, array('expire' => time() + $tYiXs, 'lifeExpire' => time() + $uy395, 'cacheSeconds' => $tYiXs)); LazyValueJob::createRefresh($PeAfP, $FRVtF, $tYiXs); } goto A9qf1; CcE_o: $l970E = array('key' => $PeAfP, 'param' => json_encode($FRVtF)); goto cH3qC; Jc55n: if (empty($BSMxd)) { goto QFvQg; OdxHc: return null; goto YyZqa; QFvQg: ModelUtil::insert('lazy_value', array('key' => $PeAfP, 'param' => json_encode($FRVtF), 'expire' => time() + $tYiXs, 'lifeExpire' => time() + $uy395, 'cacheSeconds' => $tYiXs, 'value' => null)); goto iXrBa; iXrBa: LazyValueJob::create($PeAfP, $FRVtF, $tYiXs); goto OdxHc; YyZqa: } goto Jg5BU; cH3qC: $BSMxd = ModelUtil::get('lazy_value', $l970E); goto Jc55n; ysRDO: } public static function watch() { goto rBaw7; uA2o2: $LQ7Ms = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto Nx1Q8; Nx1Q8: foreach ($LQ7Ms as $F6pCL) { LazyValueJob::createRefresh($F6pCL->key, @json_decode($F6pCL->param, true), $F6pCL->cacheSeconds); } goto my6TA; rBaw7: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto uA2o2; my6TA: } }