KeyValueMemoryFactory.php 561 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Drupal\Core\KeyValueStore;
  3. /**
  4. * Defines the key/value store factory for the memory backend.
  5. */
  6. class KeyValueMemoryFactory implements KeyValueFactoryInterface {
  7. /**
  8. * An array of keyvalue collections that are stored in memory.
  9. *
  10. * @var array
  11. */
  12. protected $collections = [];
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function get($collection) {
  17. if (!isset($this->collections[$collection])) {
  18. $this->collections[$collection] = new MemoryStorage($collection);
  19. }
  20. return $this->collections[$collection];
  21. }
  22. }