------------------------------------------------------------
revno: 1206
committer: Jakub Jankiewicz <[email protected]>
branch nick: aikiframework
timestamp: Thu 2012-05-31 18:12:42 +0200
message:
  Fix in memory cache for mysql and replace spaces with tabs in ezSQL
modified:
  libs/database/index.php
  libs/database/mysql.php


--
lp:aikiframework
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk

Your team Aiki Framework Developers is subscribed to branch lp:aikiframework.
To unsubscribe from this branch go to 
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'libs/database/index.php'
--- libs/database/index.php	2012-05-31 15:46:50 +0000
+++ libs/database/index.php	2012-05-31 16:12:42 +0000
@@ -114,9 +114,9 @@
 	}
 
     public function get_memory_cache($query) {
-        if ($this->cache_queries && isset($cached_queries[$query]) &&
-            count($cached_queries[$query]) > 0) {
-            $result_cache = $cached_queries[$query];
+        if ($this->cache_queries && isset($this->cached_queries[$query]) &&
+            count($this->cached_queries[$query]) > 0) {
+            $result_cache = $this->cached_queries[$query];
             $this->col_info = $result_cache['col_info'];
             $this->last_result = $result_cache['last_result'];
             $this->num_rows = $result_cache['num_rows'];
@@ -125,14 +125,15 @@
     }
 
     public function store_memory_cache($query, $is_insert)
-    {
-        if ($this->cache_queries && $is_insert) {
-            $cached_queries[$query] = array('col_info' => $this->col_info,
-                                            'last_result' => $this->last_result,
-                                            'num_rows' => $this->num_rows,
-                                            'return_value' => $this->num_rows);
-        }
-    }
+	{
+		if ($this->cache_queries && !$is_insert) {
+			$this->cached_queries[$query] =
+				array('col_info' => $this->col_info,
+					  'last_result' => $this->last_result,
+					  'num_rows' => $this->num_rows,
+					  'return_value' => $this->num_rows);
+		}
+	}
 
 	/**********************************************************************
 		*  Format a string correctly for safe insert - over-ridden by specific
@@ -167,7 +168,7 @@
 		$this->captured_errors[] = array
 		(
 				'error_str' => $err_str,
-				'query'     => $this->last_query
+				'query'	 => $this->last_query
 		);
 	}
 
@@ -645,11 +646,11 @@
 
 
 if (isset($config['enable_query_cache']) && $config['enable_query_cache']) {
-    $db->cache_queries = true;
+	$db->cache_queries = true;
 }
 
 if (isset($config['cache_dir']) && isset($config['use_disk_cache']) &&
-    $config['use_disk_cache']) {
+	$config['use_disk_cache']) {
 	$db->cache_timeout = !isset($config['db_cache_timeout']) ? $config['db_cache_timeout'] : 24;
 	$db->cache_dir = $config['cache_dir'];
 	$db->use_disk_cache = true;

=== modified file 'libs/database/mysql.php'
--- libs/database/mysql.php	2012-05-31 15:46:50 +0000
+++ libs/database/mysql.php	2012-05-31 16:12:42 +0000
@@ -228,10 +228,10 @@
 		// Keep track of the last query for debug..
 		$this->last_query = $query;
 
-        $memory_cache = $this->get_memory_cache($query);
-        if ($memory_cache) {
-            return $memory_cache;
-        }
+		$memory_cache = $this->get_memory_cache($query);
+		if ($memory_cache) {
+			return $memory_cache;
+		}
 
 		// Use core file cache function
 		$cache = $this->get_cache($query);
@@ -259,7 +259,7 @@
 			{
 				//check if multi database is enabled
 				if (isset ($config["allow_multiple_databases"]) and
-                    $config["allow_multiple_databases"]) {
+					$config["allow_multiple_databases"]) {
 
 					$find_request_to_external_db = preg_match('/\bfrom\b\s*(\w+)\.(\w+)/i',$query,$matches);
 					if ($find_request_to_external_db){
@@ -346,8 +346,8 @@
 
 			// disk caching of queries
 			$this->store_cache($query, $is_insert);
-            // in memory cache
-            $this->store_memory_cache($query, $is_insert);
+			// in memory cache
+			$this->store_memory_cache($query, $is_insert);
 
 			// If debug ALL queries
 			$this->trace || $this->debug_all ? $this->debug() : null ;

_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to