You are here

public function KeyValueChainedExpirableFactory::get in Supercache 2.0.x

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

Constructs a new expirable 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\KeyValueStoreExpirableInterface An expirable key/value store implementation for the given $collection.

Overrides KeyValueExpirableFactoryInterface::get

File

src/KeyValueStore/KeyValueChainedExpirableFactory.php, line 86
Contains \Drupal\supercache\KeyValueStore\KeyValueWincacheExpirableFactory.

Class

KeyValueChainedExpirableFactory
Defines the key/value store factory for the wincache/databse backend.

Namespace

Drupal\supercache\KeyValueStore

Code

public function get($collection) {
  if (!isset($this->storages[$collection])) {

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