--- apc.inc.orig	2007-09-06 19:10:01.000000000 +0200
+++ apc.inc	2008-05-05 16:30:15.000000000 +0200
@@ -20,13 +20,19 @@ $apc_page_stats = array (
  *   'cache_menu', 'cache_page', or 'cache' for the default cache.
  */
 function cache_get($cid, $bin = 'cache') {
+  $cid = $_SERVER['SERVER_NAME'].'_'.$cid;
+  
   $cache = apc_handle_get($cid, $bin);
-  if (is_object($cache) && $cache->serialized) {
-    $cache->data = $cache->data;
+  if (is_object($cache)) {
+    if (isset($cache->serialized) && $cache->serialized) {
+      $cache->data = unserialize($cache->data);
+    }
+    return $cache;
   }
-  return $cache;
+  return 0;
 }
 
+
 /**
  * Store data in the persistent cache.
  *
@@ -49,6 +55,8 @@ function cache_get($cid, $bin = 'cache')
  *   A string containing HTTP header information for cached pages.
  */
 function cache_set($cid, $bin = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
+  $cid = $_SERVER['SERVER_NAME'].'_'.$cid;
+    
   // Create new cache object.
   $cache = new stdClass;
   $cache->cid = $cid;
@@ -59,18 +67,20 @@ function cache_set($cid, $bin = 'cache',
 
   // If error on set, add it to the database cache
   if (!apc_handle_set($cid, $cache, $expire, $bin)) {
-    watchdog("Unable to set apc cache: $bin -> $cid", WATCHDOG_ERROR);
+    watchdog('apc', "Unable to set apc cache: $bin -> $cid", WATCHDOG_ERROR);
   }
 }
 
-function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) {
-  $table = empty($table) ? 'cache' : $table;
+function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) {  
+  $table = empty($bin) ? 'cache' : $bin;
+
   if (empty($cid)) {
     apc_handle_flush($table);
   }
   else {
+    $cid = $_SERVER['SERVER_NAME'].'_'.$cid;
     apc_handle_delete($cid, $table);
-  }
+  } 
 }
 
 /**
@@ -163,8 +173,7 @@ function apc_handle_set($key, $data, $ex
 function apc_handle_delete($key, $bin = 'cache') {
   global $apc_page_stats;
   $apc_page_stats['delete']++;
-  
-  if (!empty($key) && !empty($data)) {
+  if (!empty($key) && !empty($bin)) {
     $full_key = apc_handle_key($key, $bin);
     if (!apc_delete($full_key)) {
       watchdog('apc', 'Failed to delete key: ' . $full_key, WATCHDOG_ERROR);
