Version 1
[yaffs-website] / web / core / lib / Drupal / Core / KeyValueStore / KeyValueMemoryFactory.php
diff --git a/web/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php b/web/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php
new file mode 100644 (file)
index 0000000..701e2bd
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\Core\KeyValueStore;
+
+/**
+ * Defines the key/value store factory for the memory backend.
+ */
+class KeyValueMemoryFactory implements KeyValueFactoryInterface {
+
+  /**
+   * An array of keyvalue collections that are stored in memory.
+   *
+   * @var array
+   */
+  protected $collections = [];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function get($collection) {
+    if (!isset($this->collections[$collection])) {
+      $this->collections[$collection] = new MemoryStorage($collection);
+    }
+    return $this->collections[$collection];
+  }
+
+}