From fd2cac6ea517c31f8948c1e2ec06475450976f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Pel=C3=A1ez?= Date: Thu, 21 Jan 2016 15:38:35 +0100 Subject: [PATCH] Added cache to modGetPath. --- bin/modGetPath.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/modGetPath.php b/bin/modGetPath.php index ca538f7..96b514f 100644 --- a/bin/modGetPath.php +++ b/bin/modGetPath.php @@ -22,16 +22,22 @@ if (!class_exists("commandModGetPath")) { class commandModGetPath extends driverCommand { - + protected static $cache = array(); + public static function runMe(&$params, $debug = true) { $params = array_merge(array( 'name' => '' ), $params); - $sql = 'select `path` from `node_modules` where `title` = \''.$params['name'].'\''; - $resp = ''; - $q = dbConn::get()->Execute($sql); - if (!$q->EOF) { - $resp = $q->fields['path']; + if (!isset(self::$cache[$params['name']])) { + $sql = 'select `path` from `node_modules` where `title` = \''.$params['name'].'\''; + $resp = ''; + $q = dbConn::get()->Execute($sql); + if (!$q->EOF) { + $resp = $q->fields['path']; + } + self::$cache[$params['name']] = $resp; + } else { + $resp = self::$cache[$params['name']]; } return array('path' => $resp); } @@ -68,4 +74,4 @@ public static function getAccessFlags() { } } } -return new commandModGetPath(); \ No newline at end of file +return new commandModGetPath();