时间:2021-07-01 10:21:17 帮助过:19人阅读
$invoker_function($argus); }}?>
call_user_func_array(array(D($invoker_class), $invoker_function), $argus);
call_user_func_array(array(D($invoker_class), $invoker_function), $argus);
caculate($argus); $base_str = md5($str); if($this->cache_arr[$invoker_class][$invoker_function]["key"] == $base_str) { echo "命中cache 没有查询"; //命中cache return $this->cache_arr[$invoker_class][$invoker_function]["value"]; } $new_invoker_class = str_replace("Model","", $invoker_class); $new_invoker_function = $invoker_function."_setCache"; $rs = call_user_func_array(array(D($new_invoker_class), $new_invoker_function), $argus); $this->cache_arr[$invoker_class][$invoker_function]["key"] = $base_str; $this->cache_arr[$invoker_class][$invoker_function]["value"] = $rs; return $rs; } /** * * 递归计算所有的参数,判定参数是否发生改变 */ private function caculate(&$argus) { $str = ""; foreach ($argus as $key => $value) { if(is_array($value)) { $str .= $this->caculate($argus[$key]); }else{ $str .= $value; } } return $str; } }?>
cache = D("Cache"); } public function run($a,$b,$c) { return $this->cache->get($a,$b,$c); } public function run_setCache($a,$b,$c) { return "设定3参数预定值
"; } public function run2() { return $this->cache->get(); } public function run2_setCache() { return "设定空预定值
"; }}?>
run("a","b","c"); echo $test->run("a","b","c"); echo $test->run("a","b","c"); $test2 = D("Test"); echo $test2->run("a","b","c"); echo $test2->run2(); echo $test2->run2(); echo $test2->run2(); }}?>
设定3参数预定值命中cache 没有查询设定3参数预定值命中cache 没有查询设定3参数预定值命中cache 没有查询设定3参数预定值设定空预定值命中cache 没有查询设定空预定值命中cache 没有查询设定空预定值