From 1075679e37ba85fd93c286d2d3c7e6a1ebe0b787 Mon Sep 17 00:00:00 2001 From: marcus Date: Tue, 19 May 2009 12:26:30 +0000 Subject: Refs #1027: Introducing $CONFIG->db_disable_query_cache which allows disabling of query cache for implementation in CLI mode git-svn-id: https://code.elgg.org/elgg/trunk@3296 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/lib/database.php b/engine/lib/database.php index 5989f55c3..9db5cf37c 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -57,7 +57,7 @@ throw new DatabaseException(sprintf(elgg_echo('DatabaseException:NoConnect'), $CONFIG->dbname)); // Set up cache - if (!$DB_QUERY_CACHE) + if ((!$DB_QUERY_CACHE) && (!$CONFIG->db_disable_query_cache)) $DB_QUERY_CACHE = new ElggStaticVariableCache('db_query_cache'); //array(); //$DB_QUERY_CACHE = select_default_memcache('db_query_cache'); //array(); @@ -193,7 +193,7 @@ $DB_PROFILE[] = $query; $result = mysql_query($query, $dblink); - $DB_QUERY_CACHE[$query] = -1; // Set initial cache to -1 + if ($DB_QUERY_CACHE) $DB_QUERY_CACHE[$query] = -1; // Set initial cache to -1 if (mysql_errno($dblink)) throw new DatabaseException(mysql_error($dblink) . " QUERY: " . $query); @@ -258,7 +258,7 @@ global $CONFIG, $DB_QUERY_CACHE; // Is cached? - $cached_query = $DB_QUERY_CACHE[$query]; + if ($DB_QUERY_CACHE) $cached_query = $DB_QUERY_CACHE[$query]; if ($cached_query) { if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) error_log ("$query results returned from cache"); @@ -292,7 +292,7 @@ // Cache result if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) error_log("$query results cached"); - $DB_QUERY_CACHE[$query] = $resultarray; + if ($DB_QUERY_CACHE) $DB_QUERY_CACHE[$query] = $resultarray; return $resultarray; } @@ -308,7 +308,7 @@ global $CONFIG, $DB_QUERY_CACHE; // Is cached - $cached_query = $DB_QUERY_CACHE[$query]; + if ($DB_QUERY_CACHE) $cached_query = $DB_QUERY_CACHE[$query]; if ($cached_query) { if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) error_log ("$query results returned from cache"); @@ -328,7 +328,7 @@ // Cache result (even if query returned no data if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) error_log("$query results cached"); - $DB_QUERY_CACHE[$query] = $row; + if ($DB_QUERY_CACHE) $DB_QUERY_CACHE[$query] = $row; if (!empty($callback) && is_callable($callback)) { $row = $callback($row); -- cgit v1.2.3