diff --git a/memcache.inc b/memcache.inc
index af916b3..6a27f15 100644
--- a/memcache.inc
+++ b/memcache.inc
@@ -19,6 +19,17 @@ define('MEMCACHE_WILDCARD_INVALIDATE', 86400 * 28);
 define('MEMCACHE_CONTENT_FLUSH', 'MEMCACHE_CONTENT_FLUSH');
 
 /**
+ * The current memcache schema version.
+ *
+ * Memcache does not use its own storage, and cannot run updates since it is
+ * a pluggable include rather than a module. Since it uses the variable system
+ * for persistent storage, it is necessary to version those variables to avoid
+ * conflicts when upgrading. Each time the usage of a variable is changed
+ * this constant should be incremented by 1.
+ */
+define('MEMCACHE_SCHEMA_VERSION', 0);
+
+/**
  * Return data from the persistent cache.
  *
  * Data may be stored as either plain text or as serialized data.
@@ -42,10 +53,10 @@ function cache_get($cid, $table = 'cache') {
 
   // Set up common variables.
   $cache_flush = variable_get("cache_flush_$table", 0);
-  $cache_content_flush = variable_get("cache_content_flush_$table", 0);
+  $cache_content_flush = memcache_variable_get("cache_content_flush_$table", 0);
   $cache_tables = isset($_SESSION['cache_flush']) ? $_SESSION['cache_flush'] : NULL;
   $cache_lifetime = variable_get('cache_lifetime', 0);
-  $wildcard_flushes = variable_get('memcache_wildcard_flushes', array());
+  $wildcard_flushes = memcache_variable_get('memcache_wildcard_flushes', array());
   $wildcard_invalidate = variable_get('memcache_wildcard_invalidate', MEMCACHE_WILDCARD_INVALIDATE);
 
   if (is_object($cache)) {
@@ -308,7 +319,7 @@ function memcache_wildcards($cid, $table, $flush = FALSE) {
   $matching = array();
   $length = strlen($cid);
 
-  $wildcard_flushes = variable_get('memcache_wildcard_flushes', array());
+  $wildcard_flushes = memcache_variable_get('memcache_wildcard_flushes', array());
   $wildcard_invalidate = variable_get('memcache_wildcard_invalidate', MEMCACHE_WILDCARD_INVALIDATE);
 
   if (isset($wildcard_flushes[$table]) && is_array($wildcard_flushes[$table])) {
@@ -421,10 +432,16 @@ function memcache_clone($object) {
 
 /**
  * Re-implementation of variable_set() that writes through instead of clearing.
+ *
+ * ALso handles versioning of variables.
  */
 function memcache_variable_set($name, $value) {
   global $conf;
 
+  // Append the current memcache schema version to the variable name.
+
+  $name = $name . MEMCACHE_SCHEMA_VERSION;
+
   $serialized_value = serialize($value);
   db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name);
   if (!db_affected_rows()) {
@@ -440,3 +457,13 @@ function memcache_variable_set($name, $value) {
   // If the variables aren't cached, there's no need to do anything.
   $conf[$name] = $value;
 }
+
+/**
+ * Wrapper around variable_get(). Accounts for inability to use hook_update_N().
+ *
+ * This should only be used for variables that memcache sets itself, not for
+ * configuration variables.
+ */
+function memcache_variable_get($name, $default = NULL) {
+  return variable_get($name . MEMCACHE_SCHEMA_VERSION, $default);
+}
