Skip to content

Commit

Permalink
Added cache to modGetPath.
Browse files Browse the repository at this point in the history
  • Loading branch information
PSF1 committed Jan 21, 2016
1 parent 6165092 commit fd2cac6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bin/modGetPath.php
Expand Up @@ -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);
}
Expand Down Expand Up @@ -68,4 +74,4 @@ public static function getAccessFlags() {
}
}
}
return new commandModGetPath();
return new commandModGetPath();

0 comments on commit fd2cac6

Please sign in to comment.