Commit d56ced2a authored by Dries's avatar Dries
Browse files

- Patch #10373 by jabart/killed: performance improvement: caching the variable table improves performance with 20% when serving cached pages.
parent 80086a9e
......@@ -38,14 +38,23 @@ function conf_init() {
* file.
*/
function variable_init($conf = array()) {
$result = db_query('SELECT * FROM {variable} ');
// NOTE: caching the variables improves performance with 20% when serving cached pages.
if ($cached = cache_get('variables')) {
$variables = unserialize($cached->data);
}
else {
$result = db_query('SELECT * FROM {variable}');
while ($variable = db_fetch_object($result)) {
if (!isset($conf[$variable->name])) {
$conf[$variable->name] = unserialize($variable->value);
$variables[$variable->name] = unserialize($variable->value);
}
cache_set('variables', serialize($variables));
}
foreach ($conf as $name => $value) {
$variables[$name] = $value;
}
return $conf;
return $variables;
}
/**
......@@ -78,6 +87,7 @@ function variable_set($name, $value) {
db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
cache_clear_all('variables');
$conf[$name] = $value;
}
......@@ -92,6 +102,7 @@ function variable_del($name) {
global $conf;
db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
cache_clear_all('variables');
unset($conf[$name]);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment