cache the config table (this is the most common sql query)

This commit is contained in:
Shish 2009-01-19 10:47:33 -08:00
parent 6e44111e0e
commit be696e46de

View file

@ -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");
} }
} }
?> ?>