From b952f49092f714e805211e89288e3cb50470cbd3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 15 Jan 2021 20:05:06 +0800 Subject: [PATCH] 1 --- webapp/controller/BagController.class.php | 8 +++++--- webapp/controller/PayController.class.php | 15 ++++++++++----- webapp/index.php | 2 ++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 13c3a0f..a41ea4d 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -5,11 +5,13 @@ require 'classes/AddReward.php'; class BagController extends BaseAuthedController { - + private $bagTableCache = null; protected function getBag($bag_id) { - $g_conf_bag_cluster = require('../res/bag@bag.php'); - $bag_conf = getBagConfig($g_conf_bag_cluster, $bag_id); + if ($this->bagTableCache == null) { + $this->bagTableCache = require('../res/bag@bag.php'); + } + $bag_conf = getBagConfig($this->bagTableCache, $bag_id); $b = array( 'id' => $bag_conf['id'], 'name' => $bag_conf['name'], diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index fe1bf7e..7b2ea7b 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -5,11 +5,14 @@ require 'classes/AddReward.php'; class PayController extends BaseAuthedController { - + private $vipTableCache = null; + private $itemTableCache = null; protected function getItem($item_id) { - $item_meta_table = require('../res/item@item.php'); - $item_meta = getItemConfig($item_meta_table, $item_id); + if ($this->itemTableCache == null) { + $this->itemTableCache = require('../res/item@item.php'); + } + $item_meta = getItemConfig($this->itemTableCache, $item_id); $item = array( 'id' => $item_meta['id'], 'name' => $item_meta['name'], @@ -24,8 +27,10 @@ class PayController extends BaseAuthedController { protected function getVip($vip_id) { - $vip_meta_table = require('../res/vip@vip.php'); - $vip_meta = getVipConfig($vip_meta_table, $vip_id); + if ($this->vipTableCache == null) { + $this->vipTableCache = require('../res/vip@vip.php'); + } + $vip_meta = getVipConfig($this->vipTableCache, $vip_id); $vip = array( 'level' => $vip_meta['level'], 'require' => $vip_meta['require'], diff --git a/webapp/index.php b/webapp/index.php index cfd7b57..43b6f99 100644 --- a/webapp/index.php +++ b/webapp/index.php @@ -27,7 +27,9 @@ try{ $c = $_REQUEST['c']; $a = $_REQUEST['a']; $classname = $c .'Controller'; + $beginTick = phpcommon\getTickCount(); $obj = eval('$obj = new $classname(); $obj->handlePre(); $obj->$a(); $obj->handlePost();'); + //error_log('c=' . $_REQUEST['c'] . ' a=' . $_REQUEST['a'] . ' costtime:' . (phpcommon\getTickCount() - $beginTick)); } catch (Exception $e){ echo($e); }