<?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($OSU2M, $jlZvo) { return CacheUtil::rememberForever("LazyValue.{$OSU2M}", function () use($jlZvo) { return md5(serialize($jlZvo())); }); } public static function notifyChange($OSU2M) { CacheUtil::forget("LazyValue.{$OSU2M}"); } public static function status(&$qQcPQ) { foreach ($qQcPQ as $qGgGl) { if (null === $qGgGl) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($qQcPQ) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($qQcPQ), 'value' => $qQcPQ)); } public static function get($OSU2M, $uxJUJ, $yTO5u, $NQyWT = 86400) { goto iPTNB; W4UIE: if (empty($U2BR2)) { goto UQRv4; EoynS: LazyValueJob::create($OSU2M, $uxJUJ, $yTO5u); goto X8XXE; UQRv4: ModelUtil::insert('lazy_value', array('key' => $OSU2M, 'param' => json_encode($uxJUJ), 'expire' => time() + $yTO5u, 'lifeExpire' => time() + $NQyWT, 'cacheSeconds' => $yTO5u, 'value' => null)); goto EoynS; X8XXE: return null; goto MkhG3; MkhG3: } goto oj3Rw; T9kgs: return @json_decode($U2BR2['value'], true); goto CgDQ5; iPTNB: $k3Pg0 = array('key' => $OSU2M, 'param' => json_encode($uxJUJ)); goto LQhoN; oj3Rw: if ($U2BR2['expire'] < time()) { ModelUtil::update('lazy_value', $k3Pg0, array('expire' => time() + $yTO5u, 'lifeExpire' => time() + $NQyWT, 'cacheSeconds' => $yTO5u)); LazyValueJob::createRefresh($OSU2M, $uxJUJ, $yTO5u); } goto T9kgs; LQhoN: $U2BR2 = ModelUtil::get('lazy_value', $k3Pg0); goto W4UIE; CgDQ5: } public static function watch() { goto HLjB5; HLjB5: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto y_11f; p_3WV: foreach ($bwos1 as $TmEg4) { LazyValueJob::createRefresh($TmEg4->key, @json_decode($TmEg4->param, true), $TmEg4->cacheSeconds); } goto ZZaZO; y_11f: $bwos1 = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto p_3WV; ZZaZO: } }