class KeyValueExpirableFactory in MongoDB 8.2
Class KeyValueFactory builds KeyValue stores as MongoDB collections.
Hierarchy
- class \Drupal\mongodb_storage\KeyValueFactory implements KeyValueFactoryInterface
- class \Drupal\mongodb_storage\KeyValueExpirableFactory implements KeyValueExpirableFactoryInterface
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_storageView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
KeyValueExpirableFactory:: |
protected | property | The datetime.time service. | |
KeyValueExpirableFactory:: |
constant |
Overrides KeyValueFactory:: |
||
KeyValueExpirableFactory:: |
public | function |
Constructs a new key/value store for a given collection name. Overrides KeyValueFactory:: |
|
KeyValueExpirableFactory:: |
public | function |
KeyValueExpirableFactory constructor. Overrides KeyValueFactory:: |
|
KeyValueFactory:: |
protected | property | The database in which the stores are created. | |
KeyValueFactory:: |
protected | property | A static cache for the stores. | |
KeyValueFactory:: |
constant |