You are here

protected function DatabaseStorage::doSet in Drupal 9

Saves a value for a given key.

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

Parameters

string $key: The key of the data to store.

mixed $value: The data to store.

1 call to DatabaseStorage::doSet()
DatabaseStorage::set in core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
Saves a value for a given key.

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php, line 129

Class

DatabaseStorage
Defines a default key/value store implementation.

Namespace

Drupal\Core\KeyValueStore

Code

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