Permalink
Browse files

Making DboSource::$methodCache a static variable to be able to share …

…the cache between multiple instances of the same class
  • Loading branch information...
1 parent 58282c3 commit a786f4b1c605751c9c6a95528b66f159db83b25b @lorenzo lorenzo committed Jul 18, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/Cake/Model/Datasource/DboSource.php
@@ -62,7 +62,7 @@ class DboSource extends DataSource {
* @var array
* @access public
*/
- public $methodCache = array();
+ public static $methodCache = array();
/**
* Whether or not to cache the results of DboSource::name() and DboSource::conditions()
@@ -753,7 +753,8 @@ public function field($name, $sql) {
* @return void
*/
public function flushMethodCache() {
- $this->methodCache = array();
+ $this->_methodCacheChange = true;
+ self::$methodCache = array();
}
/**
@@ -772,14 +773,14 @@ public function cacheMethod($method, $key, $value = null) {
if ($this->cacheMethods === false) {
return $value;
}
- if (empty($this->methodCache)) {
- $this->methodCache = Cache::read('method_cache', '_cake_core_');
+ if (empty(self::$methodCache)) {
+ self::$methodCache = Cache::read('method_cache', '_cake_core_');
}
if ($value === null) {
- return (isset($this->methodCache[$method][$key])) ? $this->methodCache[$method][$key] : null;
+ return (isset(self::$methodCache[$method][$key])) ? self::$methodCache[$method][$key] : null;
}
$this->_methodCacheChange = true;
- return $this->methodCache[$method][$key] = $value;
+ return self::$methodCache[$method][$key] = $value;
}
/**

0 comments on commit a786f4b

Please sign in to comment.