--- cache.inc	2011-01-08 11:52:16.342278231 +1100
+++ cache.new	2011-01-07 22:22:35.862205543 +1100
@@ -106,10 +106,12 @@
     $serialized = 1;
   }
   $created = time();
+  db_lock_table('cache');
   db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, $created, $expire, $headers, $serialized, $cid);
   if (!db_affected_rows()) {
     @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, $created, $expire, $headers, $serialized);
   }
+  db_unlock_tables();
 }
 
 /**
