Added ability to turn off database auto-cache from the config
Probably should make it a part of the model as well, assuming it doesn't already do that, pretty sure it doesn't. Would help me as one of my sites I need to migrate a ton of code, so being able to flip models on one by one would be excellent.
This commit is contained in:
parent
b41f2c12e9
commit
a0ad85e8e9
2 changed files with 18 additions and 10 deletions
|
@ -300,6 +300,7 @@ class Model extends Object
|
|||
|
||||
// Gets an instance of the database and check which it is
|
||||
$this->db = Database::getInstance();
|
||||
$this->use_cache = $this->db->cache;
|
||||
$this->mysql = ($this->db->driver == 'pdo_mysql');
|
||||
$this->postgresql = ($this->db->driver == 'pdo_pgsql');
|
||||
|
||||
|
@ -459,7 +460,7 @@ class Model extends Object
|
|||
|
||||
$query_database = true;
|
||||
|
||||
if (isset($cache_key))
|
||||
if (isset($cache_key) && $this->use_cache)
|
||||
{
|
||||
$cached = $this->cache->get($cache_key);
|
||||
}
|
||||
|
@ -475,7 +476,7 @@ class Model extends Object
|
|||
(count($this->input_parameters) == 0 ? null : $this->input_parameters)
|
||||
);
|
||||
|
||||
if (isset($cache_key))
|
||||
if (isset($cache_key) && $this->use_cache)
|
||||
{
|
||||
$this->cache->set($cache_key, $this->records);
|
||||
}
|
||||
|
@ -1210,7 +1211,7 @@ class Model extends Object
|
|||
$results = $this->db->execute($sql, $input_parameters);
|
||||
|
||||
// Clears the cache
|
||||
if ($update)
|
||||
if ($update && $this->use_cache)
|
||||
{
|
||||
$this->cache->delete($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
}
|
||||
|
@ -1264,7 +1265,10 @@ class Model extends Object
|
|||
$results = $this->db->execute($sql, $input_parameters);
|
||||
|
||||
// Clears the cache
|
||||
if ($this->use_cache)
|
||||
{
|
||||
$this->cache->delete($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
|
10
jar.php
10
jar.php
|
@ -4365,6 +4365,7 @@ class Model extends Object
|
|||
|
||||
// Gets an instance of the database and check which it is
|
||||
$this->db = Database::getInstance();
|
||||
$this->use_cache = $this->db->cache;
|
||||
$this->mysql = ($this->db->driver == 'pdo_mysql');
|
||||
$this->postgresql = ($this->db->driver == 'pdo_pgsql');
|
||||
|
||||
|
@ -4524,7 +4525,7 @@ class Model extends Object
|
|||
|
||||
$query_database = true;
|
||||
|
||||
if (isset($cache_key))
|
||||
if (isset($cache_key) && $this->use_cache)
|
||||
{
|
||||
$cached = $this->cache->get($cache_key);
|
||||
}
|
||||
|
@ -4540,7 +4541,7 @@ class Model extends Object
|
|||
(count($this->input_parameters) == 0 ? null : $this->input_parameters)
|
||||
);
|
||||
|
||||
if (isset($cache_key))
|
||||
if (isset($cache_key) && $this->use_cache)
|
||||
{
|
||||
$this->cache->set($cache_key, $this->records);
|
||||
}
|
||||
|
@ -5275,7 +5276,7 @@ class Model extends Object
|
|||
$results = $this->db->execute($sql, $input_parameters);
|
||||
|
||||
// Clears the cache
|
||||
if ($update)
|
||||
if ($update && $this->use_cache)
|
||||
{
|
||||
$this->cache->delete($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
}
|
||||
|
@ -5329,7 +5330,10 @@ class Model extends Object
|
|||
$results = $this->db->execute($sql, $input_parameters);
|
||||
|
||||
// Clears the cache
|
||||
if ($this->use_cache)
|
||||
{
|
||||
$this->cache->delete($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue