You are here

public function KeyValueChainedFactory::get in Supercache 8

Same name and namespace in other branches
  1. 2.0.x src/KeyValueStore/KeyValueChainedFactory.php \Drupal\supercache\KeyValueStore\KeyValueChainedFactory::get()

Constructs a new key/value store for a given collection name.

Parameters

string $collection: The name of the collection holding key and value pairs.

Return value

\Drupal\Core\KeyValueStore\KeyValueStoreInterface A key/value store implementation for the given $collection.

Overrides KeyValueFactoryInterface::get

File

src/KeyValueStore/KeyValueChainedFactory.php, line 77
Contains \Drupal\supercache\KeyValueStore\KeyValueChainedFactory.

Class

KeyValueChainedFactory
Defines the key/value store factory for the database backend.

Namespace

Drupal\supercache\KeyValueStore

Code

public function get($collection) {

  // Do not chain if the database will
  // be taking care of caching.
  if ($this
    ->backedByDatabase()) {
    return new \Drupal\Core\KeyValueStore\DatabaseStorage($collection, $this->serializer, $this->connection);
  }
  return new ChainedStorage($this->factory, $collection, $this->serializer, $this->connection);
}