class KeyValueDatabaseExpirableFactory

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

Hierarchy

Expanded class hierarchy of KeyValueDatabaseExpirableFactory

1 string reference to 'KeyValueDatabaseExpirableFactory'
core.services.yml in drupal/core/core.services.yml
drupal/core/core.services.yml

File

drupal/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php, line 18
Contains Drupal\Core\KeyValueStore\KeyValueDatabaseExpirableFactory.

Namespace

Drupal\Core\KeyValueStore
View source
class KeyValueDatabaseExpirableFactory extends KeyValueDatabaseFactory implements DestructableInterface {

  /**
   * Holds references to each instantiation so they can be terminated.
   *
   * @var array
   */
  protected $storages;

  /**
   * Constructs a new key/value expirable database storage object for a given
   * collection name.
   *
   * @param string $collection
   *   The name of the collection holding key and value pairs.
   * @param \Drupal\Core\Database\Connection $connection
   *   The connection to run against.
   * @return \Drupal\Core\KeyValueStore\DatabaseStorageExpirable
   *   A key/value store implementation for the given $collection.
   */
  public function get($collection) {
    $storage = new DatabaseStorageExpirable($collection, $this->connection);
    $this->storages[] = $storage;
    return $storage;
  }

  /**
   * Implements Drupal\Core\DestructableInterface::terminate().
   */
  public function destruct() {
    foreach ($this->storages as $storage) {
      $storage
        ->destruct();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
KeyValueDatabaseExpirableFactory::$storages protected property Holds references to each instantiation so they can be terminated.
KeyValueDatabaseExpirableFactory::destruct public function Implements Drupal\Core\DestructableInterface::terminate(). Overrides DestructableInterface::destruct
KeyValueDatabaseExpirableFactory::get public function Constructs a new key/value expirable database storage object for a given collection name. Overrides KeyValueDatabaseFactory::get
KeyValueDatabaseFactory::__construct function Constructs this factory object.