<?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($FYJFh, $NOPYJ) { return CacheUtil::rememberForever("LazyValue.{$FYJFh}", function () use($NOPYJ) { return md5(serialize($NOPYJ())); }); } public static function notifyChange($FYJFh) { CacheUtil::forget("LazyValue.{$FYJFh}"); } public static function status(&$VRDYW) { foreach ($VRDYW as $nfRLq) { if (null === $nfRLq) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($VRDYW) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($VRDYW), 'value' => $VRDYW)); } public static function get($FYJFh, $quZRe, $XbYj3, $X1jcm = 86400) { goto azgbM; TeVzL: $tK2Fi = ModelUtil::get('lazy_value', $LUhqT); goto Pch9x; PQblS: return @json_decode($tK2Fi['value'], true); goto FDkB1; azgbM: $LUhqT = array('key' => $FYJFh, 'param' => json_encode($quZRe)); goto TeVzL; Pch9x: if (empty($tK2Fi)) { goto HmGHY; IOx2G: LazyValueJob::create($FYJFh, $quZRe, $XbYj3); goto dtxWx; HmGHY: ModelUtil::insert('lazy_value', array('key' => $FYJFh, 'param' => json_encode($quZRe), 'expire' => time() + $XbYj3, 'lifeExpire' => time() + $X1jcm, 'cacheSeconds' => $XbYj3, 'value' => null)); goto IOx2G; dtxWx: return null; goto dcvah; dcvah: } goto eqXUm; eqXUm: if ($tK2Fi['expire'] < time()) { ModelUtil::update('lazy_value', $LUhqT, array('expire' => time() + $XbYj3, 'lifeExpire' => time() + $X1jcm, 'cacheSeconds' => $XbYj3)); LazyValueJob::createRefresh($FYJFh, $quZRe, $XbYj3); } goto PQblS; FDkB1: } public static function watch() { goto dD6xl; TwtiJ: $D_VlI = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto boiJD; boiJD: foreach ($D_VlI as $duruy) { LazyValueJob::createRefresh($duruy->key, @json_decode($duruy->param, true), $duruy->cacheSeconds); } goto R1uKy; dD6xl: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto TwtiJ; R1uKy: } }