diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-09-08 18:06:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-09-08 18:06:04 +0000 |
commit | d56ced2a067476c1d063a3c136c38ca1603f6480 (patch) | |
tree | b4b24a2d5e0be3dfa724d73892e33a6071dc1819 /includes | |
parent | 80086a9e020645dc54edccf347048e6491b73dde (diff) | |
download | brdo-d56ced2a067476c1d063a3c136c38ca1603f6480.tar.gz brdo-d56ced2a067476c1d063a3c136c38ca1603f6480.tar.bz2 |
- Patch #10373 by jabart/killed: performance improvement: caching the variable table improves performance with 20% when serving cached pages.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/bootstrap.inc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 3fa6b1ca2..e92547109 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -38,14 +38,23 @@ function conf_init() { * file. */ function variable_init($conf = array()) { - $result = db_query('SELECT * FROM {variable} '); - while ($variable = db_fetch_object($result)) { - if (!isset($conf[$variable->name])) { - $conf[$variable->name] = unserialize($variable->value); + // 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)) { + $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]); } |