Added caching flag to database.
This commit is contained in:
parent
237cb22990
commit
02c0eef632
4 changed files with 75 additions and 10 deletions
|
@ -9,7 +9,7 @@
|
|||
* Redistribution of these files must retain the above copyright notice.
|
||||
*
|
||||
* @author Josh Sherman <josh@gravityblvd.com>
|
||||
* @copyright Copyright 2007-2011, Josh Sherman
|
||||
* @copyright Copyright 2007-2011, Josh Sherman
|
||||
* @license http://www.opensource.org/licenses/mit-license.html
|
||||
* @package PICKLES
|
||||
* @link http://p.ickl.es
|
||||
|
@ -129,6 +129,11 @@ class Database extends Object
|
|||
{
|
||||
$instance->setDatabase($datasource['database']);
|
||||
}
|
||||
|
||||
if (isset($datasource['caching']))
|
||||
{
|
||||
$instance->setCaching($datasource['caching']);
|
||||
}
|
||||
}
|
||||
|
||||
// Caches the instance for possible reuse later
|
||||
|
|
|
@ -29,7 +29,7 @@ abstract class Database_Common extends Object
|
|||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $driver;
|
||||
protected $driver = null;
|
||||
|
||||
/**
|
||||
* Hostname for the server
|
||||
|
@ -79,6 +79,14 @@ abstract class Database_Common extends Object
|
|||
*/
|
||||
protected $database = null;
|
||||
|
||||
/**
|
||||
* Whether or not to use caching
|
||||
*
|
||||
* @access protected
|
||||
* @var boolean
|
||||
*/
|
||||
protected $caching = false;
|
||||
|
||||
/**
|
||||
* Connection resource
|
||||
*
|
||||
|
@ -176,6 +184,16 @@ abstract class Database_Common extends Object
|
|||
return $this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Caching
|
||||
*
|
||||
* @param boolean whether or not to use cache
|
||||
*/
|
||||
public function setCaching($caching)
|
||||
{
|
||||
return $this->caching = $caching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Driver
|
||||
*
|
||||
|
|
|
@ -27,6 +27,14 @@
|
|||
*/
|
||||
class Module extends Object
|
||||
{
|
||||
/**
|
||||
* Cache object
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $cache = null;
|
||||
|
||||
/**
|
||||
* Database object
|
||||
*
|
||||
|
@ -156,7 +164,8 @@ class Module extends Object
|
|||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db = Database::getInstance();
|
||||
$this->cache = Cache::getInstance();
|
||||
$this->db = Database::getInstance();
|
||||
|
||||
if ($autorun === true)
|
||||
{
|
||||
|
|
47
jar.php
47
jar.php
|
@ -415,10 +415,11 @@ class Cache extends Object
|
|||
/**
|
||||
* Set Key
|
||||
*
|
||||
* Sets key to the specified value. I've found that compression can lead to issues
|
||||
* with integers and can slow down the storage and retrieval of data (defeats the
|
||||
* purpose of caching if you ask me) and isn't supported. I've also been burned by
|
||||
* data inadvertantly being cached for infinity, hence the 5 minute default.
|
||||
* Sets key to the specified value. I've found that compression can lead to
|
||||
* issues with integers and can slow down the storage and retrieval of data
|
||||
* (defeats the purpose of caching if you ask me) and isn't supported. I've
|
||||
* also been burned by data inadvertantly being cached for infinity, hence
|
||||
* the 5 minute default.
|
||||
*
|
||||
* @param string $key key to set
|
||||
* @param mixed $value value to set
|
||||
|
@ -1396,7 +1397,7 @@ abstract class Database_Common extends Object
|
|||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $driver;
|
||||
protected $driver = null;
|
||||
|
||||
/**
|
||||
* Hostname for the server
|
||||
|
@ -1446,6 +1447,14 @@ abstract class Database_Common extends Object
|
|||
*/
|
||||
protected $database = null;
|
||||
|
||||
/**
|
||||
* Whether or not to use caching
|
||||
*
|
||||
* @access protected
|
||||
* @var boolean
|
||||
*/
|
||||
protected $caching = false;
|
||||
|
||||
/**
|
||||
* Connection resource
|
||||
*
|
||||
|
@ -1543,6 +1552,16 @@ abstract class Database_Common extends Object
|
|||
return $this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Caching
|
||||
*
|
||||
* @param boolean whether or not to use cache
|
||||
*/
|
||||
public function setCaching($caching)
|
||||
{
|
||||
return $this->caching = $caching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Driver
|
||||
*
|
||||
|
@ -2065,7 +2084,7 @@ class Database_PDO_SQLite extends Database_PDO_Common
|
|||
* Redistribution of these files must retain the above copyright notice.
|
||||
*
|
||||
* @author Josh Sherman <josh@gravityblvd.com>
|
||||
* @copyright Copyright 2007-2011, Josh Sherman
|
||||
* @copyright Copyright 2007-2011, Josh Sherman
|
||||
* @license http://www.opensource.org/licenses/mit-license.html
|
||||
* @package PICKLES
|
||||
* @link http://p.ickl.es
|
||||
|
@ -2185,6 +2204,11 @@ class Database extends Object
|
|||
{
|
||||
$instance->setDatabase($datasource['database']);
|
||||
}
|
||||
|
||||
if (isset($datasource['caching']))
|
||||
{
|
||||
$instance->setCaching($datasource['caching']);
|
||||
}
|
||||
}
|
||||
|
||||
// Caches the instance for possible reuse later
|
||||
|
@ -5021,6 +5045,14 @@ class Model extends Object
|
|||
*/
|
||||
class Module extends Object
|
||||
{
|
||||
/**
|
||||
* Cache object
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $cache = null;
|
||||
|
||||
/**
|
||||
* Database object
|
||||
*
|
||||
|
@ -5150,7 +5182,8 @@ class Module extends Object
|
|||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db = Database::getInstance();
|
||||
$this->cache = Cache::getInstance();
|
||||
$this->db = Database::getInstance();
|
||||
|
||||
if ($autorun === true)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue