Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.69
diff -u -p -r1.69 bootstrap.inc
--- includes/bootstrap.inc	9 Oct 2005 21:51:43 -0000	1.69
+++ includes/bootstrap.inc	21 Oct 2005 08:54:59 -0000
@@ -260,21 +260,26 @@ function variable_del($name) {
 /**
  * Return data from the persistent cache.
  *
+ * @param $domain
+ *   The cache table to store the data in. Valid values are 'filter',
+ *   'locale', 'menu', 'page'.
  * @param $key
  *   The cache ID of the data to retrieve.
  */
-function cache_get($key) {
+function cache_get($domain, $key) {
   global $user;
 
+  $table = cache_get_table();
+
   // Garbage collection necessary when enforcing a minimum cache lifetime
   $cache_flush = variable_get('cache_flush', 0);
   if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) {
     // Time to flush old cache data
-    db_query("DELETE FROM {cache} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush);
+    db_query("DELETE FROM {%s} WHERE expire != %d AND expire <= %d", $table, CACHE_PERMANENT, $cache_flush);
     variable_set('cache_flush', 0);
   }
 
-  $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {cache} WHERE cid = '%s'", $key));
+  $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {cache_%s} WHERE cid = '%s'", $domain, $key));
   if (isset($cache->data)) {
     // If the data is permanent or we're not enforcing a minimum cache lifetime
     // always return the cached data.
@@ -303,6 +308,9 @@ function cache_get($key) {
 /**
  * Store data in the persistent cache.
  *
+ * @param $domain
+ *   The cache table to store the data in. Valid values are 'filter', 
+ *   'locale', 'menu', 'page'.
  * @param $cid
  *   The cache ID of the data to store.
  * @param $data
@@ -318,13 +326,15 @@ function cache_get($key) {
  * @param $headers
  *   A string containing HTTP header information for cached pages.
  */
-function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) {
+function cache_set($domain, $cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) {
   $data = db_encode_blob($data);
 
+  $table = cache_get_table($domain);
+
   db_lock_table('cache');
-  db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid);
+  db_query("UPDATE {%s} SET data = '%s', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
   if (!db_affected_rows()) {
-    @db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s')", $cid, $data, time(), $expire, $headers);
+      @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
   }
   db_unlock_tables();
 }
@@ -340,9 +350,11 @@ function cache_set($cid, $data, $expire 
  *   If set to true, the $cid is treated as a substring to match rather than a
  *   complete ID.
  */
-function cache_clear_all($cid = NULL, $wildcard = false) {
+function cache_clear_all($domain, $cid = NULL, $wildcard = false) {
   global $user;
 
+  $table = cache_get_table($domain);
+
   if (empty($cid)) {
     if (variable_get('cache_lifetime', 0)) {
       // We store the time in the current user's $user->cache variable which
@@ -359,21 +371,21 @@ function cache_clear_all($cid = NULL, $w
       else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
         // Clear the cache for everyone, cache_flush_delay seconds have
         // passed since the first request to clear the cache.
-        db_query("DELETE FROM {cache} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
+        db_query("DELETE FROM {%s} WHERE expire != %d AND expire < %d", $table, CACHE_PERMANENT, time());
         variable_set('cache_flush', 0);
       }
     }
     else {
       // No minimum cache lifetime, flush all temporary cache entries now.
-      db_query("DELETE FROM {cache} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
+      db_query("DELETE FROM {%s} WHERE expire != %d AND expire < %d", $table, CACHE_PERMANENT, time());
     }
   }
   else {
     if ($wildcard) {
-      db_query("DELETE FROM {cache} WHERE cid LIKE '%%%s%%'", $cid);
+      db_query("DELETE FROM {%s} WHERE cid LIKE '%%%s%%'", $table, $cid);
     }
     else {
-      db_query("DELETE FROM {cache} WHERE cid = '%s'", $cid);
+      db_query("DELETE FROM {%s} WHERE cid = '%s'", $table, $cid);
     }
   }
 }
@@ -412,7 +424,7 @@ function page_set_cache() {
       }
       ob_end_flush();
       if ($cache && $data) {
-        cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers());
+        cache_set('page', $base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers());
       }
     }
   }
@@ -432,7 +444,7 @@ function page_get_cache() {
   $cache = NULL;
 
   if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && count(drupal_set_message()) == 0) {
-    $cache = cache_get($base_url . request_uri());
+    $cache = cache_get('page', $base_url . request_uri());
 
     if (empty($cache)) {
       ob_start();
@@ -443,6 +455,24 @@ function page_get_cache() {
 }
 
 /**
+ * Helper function for cache functions.
+ */
+function cache_get_table($domain) {
+  switch ($domain) {
+    case 'filter':
+    case 'locale':
+    case 'menu':
+    case 'page':
+      $table = 'cache_'. $domain;
+      break;
+    default:
+      $table = 'cache';
+      break;
+  }
+  return $table;
+}
+
+/**
  * Call all init or exit hooks without including all modules.
  *
  * @param $op
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.55
diff -u -p -r1.55 locale.inc
--- includes/locale.inc	13 Oct 2005 10:02:31 -0000	1.55
+++ includes/locale.inc	21 Oct 2005 08:55:01 -0000
@@ -276,7 +276,7 @@ function _locale_import_po($file, $lang,
   }
 
   // rebuild locale cache
-  cache_clear_all("locale:$lang");
+  cache_clear_all('locale', $lang);
 
   // rebuild the menu, strings may have changed
   menu_rebuild();
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.86
diff -u -p -r1.86 menu.inc
--- includes/menu.inc	8 Oct 2005 12:38:20 -0000	1.86
+++ includes/menu.inc	21 Oct 2005 08:55:02 -0000
@@ -205,14 +205,14 @@ function menu_get_menu() {
     // _menu_build() may indirectly call this function, so prevent infinite loops.
     $_menu['items'] = array();
 
-    $cid = "menu:$user->uid:$locale";
-    if ($cached = cache_get($cid)) {
+    $cid = "$user->uid:$locale";
+    if ($cached = cache_get('menu', $cid)) {
       $_menu = unserialize($cached->data);
     }
     else {
       _menu_build();
       // Cache the menu structure for this user, to expire after one day.
-      cache_set($cid, serialize($_menu), time() + (60 * 60 * 24));
+      cache_set('menu', $cid, serialize($_menu), time() + (60 * 60 * 24));
     }
 
     // Make sure items that cannot be cached are added.
@@ -499,9 +499,9 @@ function menu_in_active_trail($mid) {
  */
 function menu_rebuild() {
   // Clear the page cache, so that changed menus are reflected for anonymous users.
-  cache_clear_all();
+  cache_clear_all('page');
   // Also clear the menu cache.
-  cache_clear_all('menu:', TRUE);
+  cache_clear_all('menu');
 
   _menu_build();
 
Index: modules/archive.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/archive.module,v
retrieving revision 1.82
diff -u -p -r1.82 archive.module
--- modules/archive.module	25 Aug 2005 21:14:16 -0000	1.82
+++ modules/archive.module	21 Oct 2005 08:55:05 -0000
@@ -60,7 +60,7 @@ function archive_calendar($original = 0)
 
   $end_of_month = mktime(23, 59, 59, $month, $last, $year);
 
-  $cache = cache_get("archive:calendar:$day-$month-$year");
+  $cache = cache_get('default', "archive:calendar:$day-$month-$year");
 
   if (!empty($cache)) {
     return $cache->data;
@@ -172,7 +172,7 @@ function archive_calendar($original = 0)
 
   $output .= "</table></div>\n\n";
 
-  cache_set("archive:calendar:$day-$month-$year", $output, CACHE_TEMPORARY);
+  cache_set('default', "archive:calendar:$day-$month-$year", $output, CACHE_TEMPORARY);
 
   return $output;
 }
Index: modules/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter.module,v
retrieving revision 1.76
diff -u -p -r1.76 filter.module
--- modules/filter.module	11 Oct 2005 19:44:34 -0000	1.76
+++ modules/filter.module	21 Oct 2005 08:55:08 -0000
@@ -350,7 +350,7 @@ function filter_admin_delete() {
       db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $edit['format']);
       db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $edit['format']);
 
-      cache_clear_all('filter:'. $edit['format'], true);
+      cache_clear_all('filter', $edit['format'], true);
 
       drupal_set_message(t('Deleted input format %format.', array('%format' => theme('placeholder', $edit['name']))));
     }
@@ -480,7 +480,7 @@ function filter_admin_filters_save($form
 
   db_query("UPDATE {filter_formats} SET cache = %d, name='%s', roles = '%s' WHERE format = %d", $cache, $name, $roles, $format);
 
-  cache_clear_all('filter:'. $format, true);
+  cache_clear_all('filter', $format, true);
 
   // if a new filter was added, return to the main list of filters, otherwise stay on edit filter page to show new changes
   if ($new) {
@@ -539,7 +539,7 @@ function filter_admin_order_save($format
   }
   drupal_set_message(t('The filter ordering has been saved.'));
 
-  cache_clear_all('filter:'. $format, true);
+  cache_clear_all('filter', $format, true);
   drupal_goto($_GET['q']);
 }
 
@@ -697,8 +697,8 @@ function check_markup($text, $format = F
     }
 
     // Check for a cached version of this piece of text.
-    $id = 'filter:'. $format .':'. md5($text);
-    if ($cached = cache_get($id)) {
+    $id = $format .':'. md5($text);
+    if ($cached = cache_get('filter', $id)) {
       return $cached->data;
     }
 
@@ -724,7 +724,7 @@ function check_markup($text, $format = F
 
     // Store in cache with a minimum expiration time of 1 day.
     if ($cache) {
-      cache_set($id, $text, time() + (60 * 60 * 24));
+        cache_set('filter', $id, $text, time() + (60 * 60 * 24));
     }
   }
   else {
Index: modules/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale.module,v
retrieving revision 1.128
diff -u -p -r1.128 locale.module
--- modules/locale.module	13 Oct 2005 10:02:31 -0000	1.128
+++ modules/locale.module	21 Oct 2005 08:55:09 -0000
@@ -128,11 +128,11 @@ function locale($string) {
 
   // Store database cached translations in a static var
   if (!isset($locale_t)) {
-    $cache = cache_get("locale:$locale");
+    $cache = cache_get('locale', $locale);
 
     if ($cache == 0) {
       locale_refresh_cache();
-      $cache = cache_get("locale:$locale");
+      $cache = cache_get('locale', $locale);
     }
     $locale_t = unserialize($cache->data);
   }
@@ -172,7 +172,7 @@ function locale($string) {
         }
       }
       // Clear locale cache in DB
-      cache_clear_all("locale:$locale");
+      cache_clear_all('locale', $locale);
     }
   }
 
@@ -189,10 +189,11 @@ function locale_refresh_cache() {
 
   foreach (array_keys($languages['name']) as $locale) {
     $result = db_query("SELECT s.source, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE t.locale = '%s' AND LENGTH(s.source) < 75", $locale);
+    $t = array();
     while ($data = db_fetch_object($result)) {
       $t[$data->source] = (empty($data->translation) ? TRUE : $data->translation);
     }
-    cache_set("locale:$locale", serialize($t));
+    cache_set('locale', $locale, serialize($t));
   }
 }
 
@@ -280,7 +281,8 @@ function locale_admin_manage() {
     }
 
     // Changing the locale settings impacts the interface:
-    cache_clear_all();
+    cache_clear_all('page');
+    cache_clear_all('');
 
     drupal_goto('admin/locale/language/overview');
   }
@@ -308,7 +310,10 @@ function locale_admin_manage_delete_scre
     }
 
     // Changing the locale settings impacts the interface:
-    cache_clear_all();
+    cache_clear_all('page');
+    cache_clear_all('');
+    // Remove stale locale cache 
+    cache_clear_all('locale', $edit['langcode']);
     drupal_goto('admin/locale/language/overview');
   }
 
