function KeyvalueMongodbFactory::get in MongoDB 8
File
- src/
KeyvalueMongodbFactory.php, line 44 - Definition of Drupal\mongodb\MongoKeyValueFactory.
Class
Namespace
Drupal\mongodbCode
function get($collection) {
$mongo_collection = "{$this->prefix}.{$collection}";
$settings = $this->settings
->get('mongo');
if (isset($settings['keyvalue']['ttl'])) {
$ttl = $settings['keyvalue']['ttl'];
}
else {
$ttl = 300;
}
$this->mongo
->get($mongo_collection)
->ensureIndex(array(
'expire' => 1,
), array(
'expireAfterSeconds' => $ttl,
));
$this->mongo
->get($mongo_collection)
->ensureIndex(array(
'_id' => 1,
'expire' => 1,
));
return new KeyvalueMongodb($this->mongo, $collection);
}