cache the config table (this is the most common sql query)
This commit is contained in:
parent
6e44111e0e
commit
be696e46de
1 changed files with 10 additions and 1 deletions
|
@ -123,7 +123,15 @@ class DatabaseConfig extends BaseConfig {
|
||||||
*/
|
*/
|
||||||
public function DatabaseConfig($database) {
|
public function DatabaseConfig($database) {
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
$this->values = $this->database->db->GetAssoc("SELECT name, value FROM config");
|
|
||||||
|
$cached = $database->cache_get("config");
|
||||||
|
if($cached) {
|
||||||
|
$this->values = $cached;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->values = $this->database->db->GetAssoc("SELECT name, value FROM config");
|
||||||
|
$database->cache_set("config", $values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -139,6 +147,7 @@ class DatabaseConfig extends BaseConfig {
|
||||||
$this->database->Execute("DELETE FROM config WHERE name = ?", array($name));
|
$this->database->Execute("DELETE FROM config WHERE name = ?", array($name));
|
||||||
$this->database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $this->values[$name]));
|
$this->database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $this->values[$name]));
|
||||||
}
|
}
|
||||||
|
$database->cache_delete("config");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Reference in a new issue