--- engines/xcache.php.orig	2008-11-03 15:33:50.000000000 -0500
+++ engines/xcache.php	2009-06-12 14:51:06.000000000 -0400
@@ -27,7 +27,7 @@
     }
     
     // Get item from cache    
-    $cache = xcache_get($this->key($key));
+    $cache = unserialize(xcache_get($this->key($key)));
 
     // Update static cache
     parent::set($this->key($key), $cache);
@@ -60,19 +60,13 @@
     $cache->created = time();
     $cache->expire = $expire;
     $cache->headers = $headers;
+    $cache->data = $value;
 
-    if (!is_string($value)) {
-      $cache->serialized = TRUE;
-      $cache->data = serialize($value);
-    }
-    else { 
-      $cache->serialized = FALSE;
-      $cache->data = $value;
-    }
+    $data = serialize($cache);
 
     if (!empty($key) && $this->lock()) {
       // Get lookup table to be able to keep track of bins
-      $lookup = xcache_get($this->lookup);
+      $lookup = unserialize(xcache_get($this->lookup));
 
       // If the lookup table is empty, initialize table
       if (empty($lookup)) {
@@ -83,7 +77,7 @@
       $lookup[$this->key($key)] = 1;
 
       // Attempt to store full key and value
-      if (!xcache_set($this->key($key), $cache, $expire)) {
+      if (!xcache_set($this->key($key), $data, $expire)) {
         unset($lookup[$this->key($key)]);
         $return = FALSE;
       }
@@ -94,7 +88,8 @@
       }
       
       // Resave the lookup table (even on failure)
-      xcache_set($this->lookup, $lookup);
+      $lookup_data = serialize($lookup);
+      xcache_set($this->lookup, $lookup_data);
 
       // Remove lock.
       $this->unlock();
@@ -118,7 +113,7 @@
     
     if (substr($key, -1, 1) == '*') {
       $key = substr($key, 0, strlen($key) - 1);
-      $lookup = xcache_get($this->lookup);
+      $lookup = unserialize(xcache_get($this->lookup));
       foreach ($lookup as $k => $v) {
         if (substr($k, 0, strlen($key) - 1)) {
           xcache_unset($k);
@@ -126,7 +121,8 @@
         }
       }
       if ($this->lock()) {
-        xcache_set($this->lookup, $lookup);
+        $lookup_data = serialize($lookup);
+        xcache_set($this->lookup, $lookup_data);
         $this->unlock();
       }
     }
@@ -154,7 +150,7 @@
     parent::flush();
     if ($this->lock()) {
       // Get lookup table to be able to keep track of bins
-      $lookup = xcache_get($this->lookup);
+      $lookup = unserialize(xcache_get($this->lookup));
 
       // If the lookup table is empty, remove lock and return
       if (empty($lookup)) {
@@ -170,7 +166,8 @@
       }
 
       // Resave the lookup table (even on failure)
-      xcache_set($this->lookup, $lookup);
+      $lookup_data = serialize($lookup);
+      xcache_set($this->lookup, $lookup_data);
 
       // Remove lock
       $this->unlock();
@@ -198,7 +195,8 @@
         }
       }
     }
-    xcache_set($this->lock, TRUE);
+    $data = serialize(TRUE);
+    xcache_set($this->lock, $data);
     return TRUE;
   }
   
