public function KeyValueExpirableFactory::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 KeyValueFactory::get

File

drupal/core/lib/Drupal/Core/KeyValueStore/KeyValueExpirableFactory.php, line 26
Contains Drupal\Core\KeyValueStore\KeyValueExpirableFactory.

Class

KeyValueExpirableFactory
Defines the key/value store factory.

Namespace

Drupal\Core\KeyValueStore

Code

public function get($collection) {
  global $conf;
  if (!isset($this->stores[$collection])) {
    if (isset($conf['keyvalue_expirable_service_' . $collection])) {
      $service_name = $conf['keyvalue_expirable_service_' . $collection];
    }
    elseif (isset($conf['keyvalue_expirable_default'])) {
      $service_name = $conf['keyvalue_expirable_default'];
    }
    else {
      $service_name = 'keyvalue.expirable.database';
    }
    $this->stores[$collection] = $this->container
      ->get($service_name)
      ->get($collection);
  }
  return $this->stores[$collection];
}