You are here

public function KeyvalueMongodb::rename in MongoDB 8

Renames a key.

Parameters

string $key: The key to rename.

string $new_key: The new key name.

Overrides KeyValueStoreInterface::rename

File

src/KeyvalueMongodb.php, line 245

Class

KeyvalueMongodb
This class holds a MongoDB key-value backend.

Namespace

Drupal\mongodb

Code

public function rename($key, $new_key) {
  if ($key != $new_key && ($current = $this
    ->get($key))) {
    unset($current['_id']);
    $this
      ->set($new_key, $current);
  }
  $this
    ->delete($key);
}