Enabled caching

This commit is contained in:
Deon George
2011-05-28 19:46:46 +10:00
parent dcd6a54cb9
commit 8b685a84dd
6 changed files with 78 additions and 7 deletions

View File

@@ -17,12 +17,50 @@ class ORMTSM extends ORM {
protected $_disable_join_table_name = TRUE;
// Suppress ORMs use of limit
protected $_disable_limit = TRUE;
// To enable effective caching, this must disabled.
protected $_reload_on_wakeup = FALSE;
// Enable the formating of columns
protected $_object_formated = array();
protected $_object_formated = array();
protected $_formated = FALSE;
protected $_formats = array();
public function __construct($id = NULL) {
parent::__construct($id);
// We'll cache our query results
if ($c = $this->_db->caching($this->_table_name))
$this->cached($c);
}
/**
* Proxy method to Database list_columns.
* This enables caching of the list_columns queries. Since this doesnt
* we hard code the cache to 7 days.
*
* @return array
*/
public function list_columns() {
// We'll cache our query results
if ($this->_db->caching('SCHEMA')) {
// Set the cache key based on the database instance name and SQL
$cache_key = 'Database::query(LC:'.$this->_table_name.')';
if ($result = Cache::instance()->get($cache_key))
// Return a cached result
return $result;
}
// Proxy to database
$result = $this->_db->list_columns($this->_table_name);
// Cache the result array
if (isset($cache_key))
Cache::instance()->set($cache_key, $result, 604800);
return $result;
}
// Load our values into the ORM object
public function load_object(array $values) {
return parent::_load_values($values);