Index: dmemcache.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/memcache/dmemcache.inc,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 dmemcache.inc
--- dmemcache.inc	31 Jul 2007 11:29:41 -0000	1.1.2.7
+++ dmemcache.inc	29 Oct 2008 16:14:00 -0000
@@ -62,7 +62,17 @@ function dmemcache_get($key, $bin = 'cac
     $full_key = dmemcache_key($key, $bin);
     $result = $mc->get($full_key);
     if ($result) {
-      $_memcache_statistics['hit'][] = $key;
+      // We know when the object expired because $result->expire is the real
+      // expire time, set by dmemcache_set as $cache->expire = $expire.
+      // If the object is expired, we try to set a lock. The process that
+      // gets the lock will get a FALSE and will presumedly regenerate and
+      // re-set the item.
+      if ($result->expire && $result->expire <= time() && $mc->add($full_key .'_semaphore', '', FALSE, 30)) {
+        $result = FALSE;
+      }
+      else {
+        $_memcache_statistics['hit'][] = $key;
+      }
     }
     return $result;
   }
Index: memcache.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/memcache/memcache.inc,v
retrieving revision 1.15.2.8
diff -u -p -r1.15.2.8 memcache.inc
--- memcache.inc	12 Feb 2008 21:58:06 -0000	1.15.2.8
+++ memcache.inc	29 Oct 2008 16:14:00 -0000
@@ -58,7 +58,10 @@ function cache_set($cid, $table = 'cache
   if ($expire == CACHE_TEMPORARY) {
     $expire = variable_get('cache_lifetime', 2591999);
   }
-  dmemcache_set($cid, $cache, $expire, $table);
+  // We set expire to zero as $cache->expire holds the expire time and
+  // dmemcache_get will return a FALSE (for one process only) when the object
+  // has expired.
+  dmemcache_set($cid, $cache, 0, $table);
 }
 
 /**
