diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index e64bfca..ec218ae 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -5,6 +5,7 @@ use Symfony\Component\ClassLoader\UniversalClassLoader;
 use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Symfony\Component\HttpFoundation\Request;
+use Drupal\Component\KeyValueStore\KeyValueStore;
 
 /**
  * @file
@@ -2907,6 +2908,34 @@ function ip_address() {
   return $ip_address;
 }
 
+
+function keyvalue($collection, $options = array()) {
+  static $kv_objects = array();
+  if (!isset($kv_objects[$collection])) {
+    // Treat anything up to the first "." as the collection base.
+    if ($pos = strpos($collection, '.')) {
+      $collection_base = substr($collection, 0, strpos($collection, '.'));
+    }
+    else {
+      $collection_base = $collection;
+    }
+
+    $storage_classes = variable_get('keyvalue_storage_classes', array(
+      'default' => '\Drupal\Component\KeyValueStore\Storage\DbtngStorage')
+    );
+
+    if (isset($storage_classes[$collection_base])) {
+      $class = $storage_classes[$collection_base];
+    }
+    else {
+      $class = $storage_classes['default'];
+    }
+
+    $kv_objects[$collection] = new KeyValueStore(new $class($collection, $options));
+  }
+  return $kv_objects[$collection];
+}
+
 /**
  * @addtogroup registry
  * @{
diff --git a/core/lib/Drupal/Component/KeyValueStore/KeyValueStore.php b/core/lib/Drupal/Component/KeyValueStore/KeyValueStore.php
new file mode 100644
index 0000000..f2a32cc
--- /dev/null
+++ b/core/lib/Drupal/Component/KeyValueStore/KeyValueStore.php
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * @file
+ * Definition of KeyValueStore.
+ */
+
+namespace Drupal\Component\KeyValueStore;
+
+use Drupal\Component\KeyValueStore\Storage\StorageInterface;
+
+class KeyValueStore {
+
+  protected $storage;
+
+  public function __construct(StorageInterface $storage) {
+    $this->collection = $storage->getCollectionName();
+    $this->storage = $storage;
+  }
+
+  /**
+   * Returns data from the key/value store.
+   *
+   * @param $key
+   *   The key of the data to retrieve.
+   *
+   * @return
+   *   The value or FALSE on failure.
+   */
+  function get($key) {
+    return $this->storage->get($key);
+  }
+
+  /**
+   * Returns data from the key/value store when given an array of keys.
+   *
+   * @param $keys
+   *   An array of keys for the data to retrieve.
+   *
+   * @return
+   *   An array of the items successfully returned, indexed by key.
+   */
+  function getMultiple($keys) {
+    return $this->storage->getMultiple($keys);
+  }
+
+  /**
+   * Stores data in the key/value store.
+   *
+   * @param $key
+   *   The key of the data to store.
+   * @param $value
+   *   The data to store.
+   */
+  function set($key, $value) {
+    return $this->storage->set($key, $value);
+  }
+
+  /**
+   * Stores data in the key/value store.
+   *
+   * @param $data
+   *   An array of key/value pairs.
+   */
+  function setMultiple($data) {
+    return $this->storage->setMultiple($data);
+  }
+
+  /**
+   * Deletes an item.
+   *
+   * @param $key
+   *    The key to delete.
+   */
+  function delete($key) {
+    return $this->storage->delete($key);
+  }
+
+  /**
+   * Deletes multiple items from the key/value store.
+   *
+   * @param $keys
+   *   An array of $keys to delete.
+   */
+  function deleteMultiple(array $keys) {
+    return $this->storage->deleteMultiple($keys);
+  }
+}
diff --git a/core/lib/Drupal/Component/KeyValueStore/Storage/DbtngStorage.php b/core/lib/Drupal/Component/KeyValueStore/Storage/DbtngStorage.php
new file mode 100644
index 0000000..b69330a
--- /dev/null
+++ b/core/lib/Drupal/Component/KeyValueStore/Storage/DbtngStorage.php
@@ -0,0 +1,120 @@
+<?php
+
+/**
+ * @file
+ * Definition of DatabaseBackend.
+ */
+
+namespace Drupal\Component\KeyValueStore\Storage;
+
+/**
+ * Defines a default key/value store implementation.
+ *
+ * This is Drupal's default key/value store implementation. It uses the database to store
+ * key/value data.
+ */
+class DbtngStorage implements StorageInterface {
+
+  /**
+   * @var string
+   */
+  protected $collection;
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::__construct().
+   */
+  public function __construct($collection, array $options) {
+    $this->collection = $collection;
+    $this->table = isset($options['table']) ? $options['table'] : 'variable';
+  }
+
+  protected function prepareKey($key) {
+    return "$this->collection:$key";
+  }
+
+  public function getCollectionName() {
+    return $this->collection;
+  }
+
+  protected function prepareKeys($keys) {
+    $prepared_keys = array();
+    foreach ($keys as $k) {
+      $prepared_keys[] = "$this->collection:$k";
+    }
+    return $prepared_keys;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::get().
+   */
+  function get($key) {
+    $keys = array($key);
+    $values = $this->getMultiple($keys);
+    return reset($values);
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::getMultiple().
+   */
+  public function getMultiple($keys) {
+    $keys = $this->prepareKeys($keys);
+    try {
+      $result = db_query('SELECT name, value FROM {' . db_escape_table($this->table) . '} WHERE name IN (:keys)', array(':keys' => $keys));
+      $values = array();
+
+      foreach ($result as $item) {
+        if ($item) {
+          $values[$item->name] = unserialize($item->value);
+        }
+      }
+      return $values;
+    }
+    catch (\Exception $e) {
+      // If the database is never going to be available, key/value requests should
+      // return FALSE in order to allow exception handling to occur.
+      return array();
+    }
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::set().
+   */
+  public function set($key, $value) {
+    $key = $this->prepareKey($key);
+    db_merge($this->table)->key(array('name' => $key))->fields(array('value' => serialize($value)))->execute();
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::setMultiple().
+   */
+  public function setMultiple($data) {
+    foreach ($data as $key => $value) {
+      $key = $this->prepareKey($key);
+      $this->set($key, $value);
+    }
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::delete().
+   */
+  public function delete($key) {
+    $key = $this->prepareKey($key);
+    db_delete($this->table)
+    ->condition('name', $key)
+    ->execute();
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::deleteMultiple().
+   */
+  public function deleteMultiple(Array $keys) {
+    $keys = $this->prepareKeys($keys);
+    // Delete in chunks when a large array is passed.
+    do {
+      db_delete($this->table)
+        ->condition('key', array_splice($keys, 0, 1000), 'IN')
+        ->execute();
+    }
+    while (count($keys));
+  }
+}
diff --git a/core/lib/Drupal/Component/KeyValueStore/Storage/MemoryStorage.php b/core/lib/Drupal/Component/KeyValueStore/Storage/MemoryStorage.php
new file mode 100644
index 0000000..1a1816a
--- /dev/null
+++ b/core/lib/Drupal/Component/KeyValueStore/Storage/MemoryStorage.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * @file
+ * Definition of MemoryStorage.
+ */
+
+namespace Drupal\Component\KeyValueStore\Storage;
+
+/**
+ * Defines a default key/value store implementation.
+ */
+class MemoryStorage implements StorageInterface {
+
+  /**
+   * @var string
+   */
+  protected $collection;
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::__construct().
+   */
+  public function __construct($collection, array $parameters = array()) {
+    $this->collection = $collection;
+    $this->data = array();
+  }
+
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::getCollectionName().
+   */
+  public function getCollectionName() {
+    return $this->collection;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::get().
+   */
+  function get($key) {
+    return isset($this->data[$key]) ? $this->data[$key] : FALSE;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::getMultiple().
+   */
+  public function getMultiple($keys) {
+    $results = array();
+    foreach ($keys as $key) {
+      $results[$key] = $this->data[$key];
+    }
+    return $results;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::set().
+   */
+  public function set($key, $value) {
+    return $this->data[$key] = $value;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::setMultiple().
+   */
+  public function setMultiple($data) {
+    $this->data = $data + $this->data;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::delete().
+   */
+  public function delete($key) {
+    unset($this->data[$key]);
+    return TRUE;
+  }
+
+  /**
+   * Implements Drupal\Component\KeyValueStore\Storage\StorageInterface::deleteMultiple().
+   */
+  public function deleteMultiple(array $keys) {
+    foreach ($keys as $key) {
+      unset($this->data[$key]);
+    }
+    return TRUE;
+  }
+}
+
diff --git a/core/lib/Drupal/Component/KeyValueStore/Storage/StorageInterface.php b/core/lib/Drupal/Component/KeyValueStore/Storage/StorageInterface.php
new file mode 100644
index 0000000..6fe27e0
--- /dev/null
+++ b/core/lib/Drupal/Component/KeyValueStore/Storage/StorageInterface.php
@@ -0,0 +1,87 @@
+<?php
+
+/**
+ * @file
+ * Definition of StorageInterface.
+ */
+
+namespace Drupal\Component\KeyValueStore\Storage;
+
+/**
+ * Defines an interface for key/value implementations.
+ *
+ */
+interface StorageInterface {
+  /**
+   * Constructs a new key/value collection.
+   *
+   * @param $collection
+   *   The collection for which the object is created.
+   * @param $options
+   */
+  function __construct($collection, array $options);
+
+  /**
+   * Returns the name of the collection that was passed into the constructor.
+   *
+   * @return
+   *   Name of the collection.
+   */
+  function getCollectionName();
+
+  /**
+   * Returns data from the key/value store.
+   *
+   * @param $key
+   *   The key of the data to retrieve.
+   *
+   * @return
+   *   The value or FALSE on failure.
+   */
+  function get($key);
+
+  /**
+   * Returns data from the key/value store when given an array of keys.
+   *
+   * @param $keys
+   *   An array of keys for the data to retrieve.
+   *
+   * @return
+   *   An array of the items successfully returned, indexed by key.
+   */
+  function getMultiple($keys);
+
+  /**
+   * Stores data in the key/value store.
+   *
+   * @param $key
+   *   The key of the data to store.
+   * @param $value
+   *   The data to store.
+   */
+  function set($key, $value);
+
+  /**
+   * Stores data in the key/value store.
+   *
+   * @param $data
+   *   An array of key/value pairs.
+   */
+  function setMultiple($data);
+
+  /**
+   * Deletes an item.
+   *
+   * @param $key
+   *    The key to delete.
+   */
+  function delete($key);
+
+  /**
+   * Deletes multiple items from the key/value store.
+   *
+   * @param $keys
+   *   An array of $keys to delete.
+   */
+  function deleteMultiple(Array $keys);
+}
