function KeyvalueMongodb::setWithExpire in MongoDB 8
Saves a value for a given key with a time to live.
Parameters
string $key: The key of the data to store.
mixed $value: The data to store.
int $expire: The time to live for items, in seconds.
Overrides KeyValueStoreExpirableInterface::setWithExpire
1 call to KeyvalueMongodb::setWithExpire()
- KeyvalueMongodb::setMultipleWithExpire in src/
KeyvalueMongodb.php - Saves an array of values with a time to live.
File
- src/
KeyvalueMongodb.php, line 78
Class
- KeyvalueMongodb
- This class holds a MongoDB key-value backend.
Namespace
Drupal\mongodbCode
function setWithExpire($key, $value, $expire) {
$this
->collection()
->update(array(
'_id' => (string) $key,
), $this
->getObject($key, $value, $expire), array(
'upsert' => TRUE,
));
}