=== modified file 'includes/bootstrap.inc'--- includes/bootstrap.inc +++ includes/bootstrap.inc @@ -28,6 +28,9 @@ define('DRUPAL_BOOTSTRAP_FULL', 6); define('DRUPAL_ANONYMOUS_RID', 1); define('DRUPAL_AUTHENTICATED_RID', 2);+define('VARIABLE_SHORT_CACHE', 1);+define('VARIABLE_LONG_CACHE', 2);+ /** * Start the timer with the specified name. If you start and stop * the same timer multiple times, the measured intervals will be@@ -240,15 +243,15 @@ function drupal_get_filename($type, $nam */ function variable_init($conf = array()) { // NOTE: caching the variables improves performance with 20% when serving cached pages.- if ($cached = cache_get('variables')) {+ if ($cached = cache_get('variables_short')) { $variables = unserialize($cached->data); } else {- $result = db_query('SELECT * FROM {variable}');+ $result = db_query('SELECT * FROM {variable} WHERE delta = 1'); while ($variable = db_fetch_object($result)) { $variables[$variable->name] = unserialize($variable->value); }- cache_set('variables', serialize($variables));+ cache_set('variables_short', serialize($variables)); } foreach ($conf as $name => $value) {@@ -265,12 +268,28 @@ function variable_init($conf = array()) * The name of the variable to return. * @param $default * The default value to use if this variable has never been set.+ * @param $delta+ * Which variable cache the variable belongs to. Options are: VARIABLE_SHORT_CACHE, VARIABLE_LONG_CACHE. * @return * The value of the variable. */-function variable_get($name, $default) {+function variable_get($name, $default, $delta = VARIABLE_SHORT_CACHE) { global $conf;+ static $long_cache_loaded = NULL;+ if ($delta == VARIABLE_LONG_CACHE && !isset($long_cache_loaded)) {+ if ($cached = cache_get('variables_long')) {+ $variables = unserialize($cached->data);+ }+ else {+ $result = db_query('SELECT * FROM {variable} WHERE delta = 2');+ while ($variable = db_fetch_object($result)) {+ $variables[$variable->name] = unserialize($variable->value);+ }+ cache_set('variables_long', serialize($variables));+ }+ $conf += $variables;+ } return isset($conf[$name]) ? $conf[$name] : $default; }@@ -282,16 +301,24 @@ function variable_get($name, $default) { * @param $value * The value to set. This can be any PHP data type; these functions take care * of serialization as necessary.+ * @param $delta+ * Which variable cache to insert the variable into. Options are: VARIABLE_SHORT_CACHE, VARIABLE_LONG_CACHE. */-function variable_set($name, $value) {+function variable_set($name, $value, $delta = VARIABLE_SHORT_CACHE) { global $conf; db_lock_table('variable'); db_query("DELETE FROM {variable} WHERE name = '%s'", $name);- db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));+ db_query("INSERT INTO {variable} (name, value, delta) VALUES ('%s', '%s', %d)", $name, serialize($value), $delta); db_unlock_tables();- cache_clear_all('variables');+ if ($delta == VARIABLE_LONG_CACHE) {+ $cache = 'variables_long';+ }+ else {+ $cache = 'variables_short';+ }+ cache_clear_all($cache); $conf[$name] = $value; }