Reverted per column caching aside from id field.
Was a bit messy, just so hard to automagically cache stuff without knowing the data usage.
This commit is contained in:
parent
4d9eb54b13
commit
391e95c9e8
1 changed files with 2 additions and 58 deletions
|
@ -410,9 +410,6 @@ class Model extends Object
|
|||
$this->$variable = $value;
|
||||
}
|
||||
|
||||
// Cache fields
|
||||
$cache_field = false;
|
||||
|
||||
// Builds out the query
|
||||
if ($type_or_parameters != null)
|
||||
{
|
||||
|
@ -424,25 +421,6 @@ class Model extends Object
|
|||
throw new Exception('You cannot pass in 2 query parameter arrays');
|
||||
}
|
||||
|
||||
if ($this->use_cache && isset($type_or_parameters['conditions'])
|
||||
&& count($type_or_parameters['conditions']) == 1)
|
||||
{
|
||||
$cache_key = $this->model . '-' . key($type_or_parameters['conditions'])
|
||||
. '-' . current($type_or_parameters['conditions']);
|
||||
|
||||
$cache_id = $this->cache->get($cache_key);
|
||||
$cache_field = key($type_or_parameters['conditions']);
|
||||
|
||||
if ($cache_id === false)
|
||||
{
|
||||
unset($cache_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_key = $this->model . '-' . $cache_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->columns['is_deleted'])
|
||||
{
|
||||
$type_or_parameters['conditions'][$this->columns['is_deleted']] = '0';
|
||||
|
@ -529,13 +507,6 @@ class Model extends Object
|
|||
(count($this->input_parameters) == 0 ? null : $this->input_parameters)
|
||||
);
|
||||
|
||||
if ($this->use_cache && $cache_field && $this->count() == 1)
|
||||
{
|
||||
$this->cache->set($this->model . '-' . $cache_field . '-' . $this->records[0][$cache_field], $this->records[0][$this->columns['id']]);
|
||||
|
||||
$cache_key = $this->model . '-' . $this->records[0][$this->columns['id']];
|
||||
}
|
||||
|
||||
if (isset($cache_key) && $this->use_cache)
|
||||
{
|
||||
$this->cache->set($cache_key, $this->records);
|
||||
|
@ -1438,24 +1409,7 @@ class Model extends Object
|
|||
// Clears the cache
|
||||
if ($update && $this->use_cache)
|
||||
{
|
||||
$cache_keys = array($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
|
||||
foreach ($this->original as $original)
|
||||
{
|
||||
if ($original['id'] == $this->record['id'])
|
||||
{
|
||||
foreach ($this->original[0] as $column => $value)
|
||||
{
|
||||
if (!String::isEmpty($value) && !in_array($column, $this->columns)
|
||||
&& isset($this->record[$column]) && $value != $this->record[$column])
|
||||
{
|
||||
$cache_keys[] = $this->model . '-' . $column . '-' . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete($cache_keys);
|
||||
$this->cache->delete($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
@ -1509,17 +1463,7 @@ class Model extends Object
|
|||
// Clears the cache
|
||||
if ($this->use_cache)
|
||||
{
|
||||
$cache_keys = $this->model . '-' . $this->record[$this->columns['id']];
|
||||
|
||||
foreach ($this->record as $column => $value)
|
||||
{
|
||||
if (!in_array($column, $this->columns))
|
||||
{
|
||||
$cache_keys[] = $this->model . '-' . $column . '-' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete($cache_keys);
|
||||
$this->cache->delete($this->model . '-' . $this->record[$this->columns['id']]);
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue