You are here

protected function KeyValueStoreExpirable::getBsonExpire in MongoDB 8.2

Convert a UNIX timestamp to a BSON one for document insertion.

Parameters

int $expire: The source timestamp.

Return value

\MongoDB\BSON\UTCDateTime Its ready-to-insert counterpart.

2 calls to KeyValueStoreExpirable::getBsonExpire()
KeyValueStoreExpirable::setWithExpire in modules/mongodb_storage/src/KeyValueStoreExpirable.php
Saves a value for a given key with a time to live.
KeyValueStoreExpirable::setWithExpireIfNotExists in modules/mongodb_storage/src/KeyValueStoreExpirable.php
Sets a value for a given key with a time to live if it does not yet exist.

File

modules/mongodb_storage/src/KeyValueStoreExpirable.php, line 75

Class

KeyValueStoreExpirable
KeyValueStore provides a KeyValueStoreExpirable as a MongoDB collection.

Namespace

Drupal\mongodb_storage

Code

protected function getBsonExpire(int $expire) : UTCDateTime {
  return new UTCDateTime(1000 * ($this->time
    ->getCurrentTime() + $expire));
}