You are here

protected function DatabaseStorageExpirable::doSetWithExpire in Drupal 9

Saves a value for a given key with a time to live.

This will be called by setWithExpire() within a try block.

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.

1 call to DatabaseStorageExpirable::doSetWithExpire()
DatabaseStorageExpirable::setWithExpire in core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php
Saves a value for a given key with a time to live.

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php, line 104

Class

DatabaseStorageExpirable
Defines a default key/value store implementation for expiring items.

Namespace

Drupal\Core\KeyValueStore

Code

protected function doSetWithExpire($key, $value, $expire) {
  $this->connection
    ->merge($this->table)
    ->keys([
    'name' => $key,
    'collection' => $this->collection,
  ])
    ->fields([
    'value' => $this->serializer
      ->encode($value),
    'expire' => REQUEST_TIME + $expire,
  ])
    ->execute();
}