<?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($ySsOv, $Ikxtb) { return CacheUtil::rememberForever("LazyValue.{$ySsOv}", function () use($Ikxtb) { return md5(serialize($Ikxtb())); }); } public static function notifyChange($ySsOv) { CacheUtil::forget("LazyValue.{$ySsOv}"); } public static function status(&$sKrwM) { foreach ($sKrwM as $hf0nR) { if (null === $hf0nR) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($sKrwM) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($sKrwM), 'value' => $sKrwM)); } public static function get($ySsOv, $mzzZ3, $rBEnt, $bqqzY = 86400) { goto iP0wB; bMC6C: if ($OjlJV['expire'] < time()) { ModelUtil::update('lazy_value', $bQDKx, array('expire' => time() + $rBEnt, 'lifeExpire' => time() + $bqqzY, 'cacheSeconds' => $rBEnt)); LazyValueJob::createRefresh($ySsOv, $mzzZ3, $rBEnt); } goto fdHmy; JcTYU: if (empty($OjlJV)) { goto VaJNz; QxvTx: return null; goto OCagV; VaJNz: ModelUtil::insert('lazy_value', array('key' => $ySsOv, 'param' => json_encode($mzzZ3), 'expire' => time() + $rBEnt, 'lifeExpire' => time() + $bqqzY, 'cacheSeconds' => $rBEnt, 'value' => null)); goto vXEy8; vXEy8: LazyValueJob::create($ySsOv, $mzzZ3, $rBEnt); goto QxvTx; OCagV: } goto bMC6C; fdHmy: return @json_decode($OjlJV['value'], true); goto liy6k; iP0wB: $bQDKx = array('key' => $ySsOv, 'param' => json_encode($mzzZ3)); goto YcwlM; YcwlM: $OjlJV = ModelUtil::get('lazy_value', $bQDKx); goto JcTYU; liy6k: } public static function watch() { goto y_0_D; YQRMD: foreach ($CTAsN as $PuZZz) { LazyValueJob::createRefresh($PuZZz->key, @json_decode($PuZZz->param, true), $PuZZz->cacheSeconds); } goto iPChN; yHxta: $CTAsN = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto YQRMD; y_0_D: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto yHxta; iPChN: } }