Mercurial > hg > batmud > maputils
changeset 1150:02fe48a608d7
Use APC for caching of location and wizard data.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 21 Jul 2011 20:38:06 +0300 |
parents | f6a7922425fd |
children | e0794ddb605e |
files | www/info.php www/loc.php www/ss.php |
diffstat | 3 files changed, 40 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/www/info.php Thu Jul 21 20:36:17 2011 +0300 +++ b/www/info.php Thu Jul 21 20:38:06 2011 +0300 @@ -36,8 +36,16 @@ </div> <? -$locTable = readLocationFiles(); -$wizTable = readWizInfoFiles(); +$locTable = apc_fetch("info_locTable"); +if (empty($locTable)) { + $locTable = readLocationFiles(); + apc_store("info_locTable", $locTable, 3600); +} +$wizTable = apc_fetch("wizTable"); +if (empty($wizTable)) { + $wizTable = readWizInfoFiles(); + apc_store("wizTable", $wizTable, 3600); +} if (isset($_GET["a"])) {
--- a/www/loc.php Thu Jul 21 20:36:17 2011 +0300 +++ b/www/loc.php Thu Jul 21 20:38:06 2011 +0300 @@ -64,22 +64,37 @@ if (preg_match("#^([a-z]{1,15})#i", $_GET["a"], $m)) { $coderName = $m[1]; $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); - $wizTable = readWizInfoFiles(); - } else + + $wizTable = apc_fetch("wizTable"); + if (empty($wizTable)) { + $wizTable = readWizInfoFiles(); + apc_store("wizTable", $wizTable, 3600); + } + } else { $coderName = "???"; + $errorStr = "Invalid wizard name."; + } } if (isset($_GET["n"])) { $locTable = array(); $setName = strtolower(basename($_GET["n"])); if (file_exists($setName.".loc")) { - parseLocFile($setName, $locTable, $applyFilter, $filter); + $locTable = apc_fetch("loc_".$setName); + if (empty($locTable)) { + parseLocFile($setName, $locTable, $applyFilter, $filter); + apc_store("loc_".$setName, $locTable, 3600); + } } else { $errorStr = "No such continent ID!"; unset($setName); } } else { - $locTable = readLocationFiles($applyFilter, $filter); + $locTable = apc_fetch("loc_locTable"); + if (empty($locTable)) { + $locTable = readLocationFiles($applyFilter, $filter); + apc_store("loc_locTable", $locTable, 3600); + } } @@ -158,7 +173,8 @@ <? /* Wizard/coder/creator information box */ -if (isset($coderName) && isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) { +if (isset($coderName)) { + if (isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) { // Profile picture $s = $wizTable[$coderName]["imageURL"]; @@ -196,6 +212,8 @@ } echo " </td>\n </tr>\n </table>\n</div>\n"; + } else + $errorStr = "No such wizard."; } @@ -354,6 +372,7 @@ } else { echo "<p><b>No locations known!</b></p>\n"; echo "</div>\n"; + $errorStr = "No locations known!"; } ?> </body>
--- a/www/ss.php Thu Jul 21 20:36:17 2011 +0300 +++ b/www/ss.php Thu Jul 21 20:38:06 2011 +0300 @@ -2,8 +2,12 @@ require "config.inc.php"; require "common.inc.php"; -$locTable = readLocationFiles(TRUE, "C", TRUE); -parseLocFile("limbo", $locTable, TRUE, "C"); +$locTable = apc_fetch("ss_locTable"); +if (empty($locTable)) { + $locTable = readLocationFiles(TRUE, "C", TRUE); + parseLocFile("limbo", $locTable, TRUE, "C"); + apc_store("ss_locTable", $locTable, 3600); +} /* Page start */