You are here

class KeyValueExpirableFactory in MongoDB 8.2

Class KeyValueFactory builds KeyValue stores as MongoDB collections.

Hierarchy

Expanded class hierarchy of KeyValueExpirableFactory

2 files declare their use of KeyValueExpirableFactory
SqlImport.php in modules/mongodb_storage/src/Install/SqlImport.php
SqlImportTest.php in modules/mongodb_storage/tests/src/Kernel/SqlImportTest.php
1 string reference to 'KeyValueExpirableFactory'
mongodb_storage.services.yml in modules/mongodb_storage/mongodb_storage.services.yml
modules/mongodb_storage/mongodb_storage.services.yml
1 service uses KeyValueExpirableFactory
keyvalue.expirable.mongodb in modules/mongodb_storage/mongodb_storage.services.yml
Drupal\mongodb_storage\KeyValueExpirableFactory

File

modules/mongodb_storage/src/KeyValueExpirableFactory.php, line 14

Namespace

Drupal\mongodb_storage
View source
class KeyValueExpirableFactory extends KeyValueFactory implements KeyValueExpirableFactoryInterface {
  const COLLECTION_PREFIX = 'kve_';

  /**
   * The datetime.time service.
   *
   * @var \Drupal\Component\Datetime\TimeInterface
   */
  protected $time;

  /**
   * KeyValueExpirableFactory constructor.
   *
   * @param \Drupal\mongodb\DatabaseFactory $databaseFactory
   *   The mongodb.database_factory service.
   * @param \Drupal\Component\Datetime\TimeInterface $time
   *   The datetime.time service.
   */
  public function __construct(DatabaseFactory $databaseFactory, TimeInterface $time) {
    parent::__construct($databaseFactory);
    $this->time = $time;
  }

  /**
   * Constructs a new key/value store for a given collection name.
   *
   * @param string $collection
   *   The name of the collection holding key and value pairs.
   *
   * @return \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface
   *   A key/value store implementation for the given $collection.
   *
   * @see drush_mongodb_storage_import_keyvalue()
   */
  public function get($collection) {
    $storeCollection = $this->database
      ->selectCollection(static::COLLECTION_PREFIX . $collection);
    $store = new KeyValueStoreExpirable($collection, $storeCollection);
    $store
      ->setTimeService($this->time);
    return $store;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
KeyValueExpirableFactory::$time protected property The datetime.time service.
KeyValueExpirableFactory::COLLECTION_PREFIX constant Overrides KeyValueFactory::COLLECTION_PREFIX
KeyValueExpirableFactory::get public function Constructs a new key/value store for a given collection name. Overrides KeyValueFactory::get
KeyValueExpirableFactory::__construct public function KeyValueExpirableFactory constructor. Overrides KeyValueFactory::__construct
KeyValueFactory::$database protected property The database in which the stores are created.
KeyValueFactory::$stores protected property A static cache for the stores.
KeyValueFactory::DB_KEYVALUE constant