<?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($rY0hM, $hy4YA) { return CacheUtil::rememberForever("LazyValue.{$rY0hM}", function () use($hy4YA) { return md5(serialize($hy4YA())); }); } public static function notifyChange($rY0hM) { CacheUtil::forget("LazyValue.{$rY0hM}"); } public static function status(&$hsART) { foreach ($hsART as $YxV2x) { if (null === $YxV2x) { return 'running'; } } return 'finish'; } public static function generateResponseWithStatus($hsART) { return Response::generate(0, 'ok', array('status' => LazyValueUtil::status($hsART), 'value' => $hsART)); } public static function get($rY0hM, $EPwwc, $qUOYa, $pjqmi = 86400) { goto QYhZq; Ot8Ky: $e8n8Q = ModelUtil::get('lazy_value', $HBsr7); goto ea2kS; ea2kS: if (empty($e8n8Q)) { goto Sxc43; j_2Aa: return null; goto gvc2G; g5qTz: LazyValueJob::create($rY0hM, $EPwwc, $qUOYa); goto j_2Aa; Sxc43: ModelUtil::insert('lazy_value', array('key' => $rY0hM, 'param' => json_encode($EPwwc), 'expire' => time() + $qUOYa, 'lifeExpire' => time() + $pjqmi, 'cacheSeconds' => $qUOYa, 'value' => null)); goto g5qTz; gvc2G: } goto cPuT0; qI5ao: return @json_decode($e8n8Q['value'], true); goto frCsm; cPuT0: if ($e8n8Q['expire'] < time()) { ModelUtil::update('lazy_value', $HBsr7, array('expire' => time() + $qUOYa, 'lifeExpire' => time() + $pjqmi, 'cacheSeconds' => $qUOYa)); LazyValueJob::createRefresh($rY0hM, $EPwwc, $qUOYa); } goto qI5ao; QYhZq: $HBsr7 = array('key' => $rY0hM, 'param' => json_encode($EPwwc)); goto Ot8Ky; frCsm: } public static function watch() { goto FXgtj; FXgtj: ModelUtil::model('lazy_value')->where('lifeExpire', '<', time())->delete(); goto zB5Sc; FY9VQ: foreach ($IhAgr as $Tsb75) { LazyValueJob::createRefresh($Tsb75->key, @json_decode($Tsb75->param, true), $Tsb75->cacheSeconds); } goto bT13B; zB5Sc: $IhAgr = ModelUtil::model('lazy_value')->where('expire', '<', time())->get(array('key', 'param', 'cacheSeconds')); goto FY9VQ; bT13B: } }