You are here

public function KeyvalueMongodb::set in MongoDB 8

Saves a value for a given key.

Parameters

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

mixed $value: The data to store.

Overrides KeyValueStoreInterface::set

1 call to KeyvalueMongodb::set()
KeyvalueMongodb::rename in src/KeyvalueMongodb.php
Renames a key.

File

src/KeyvalueMongodb.php, line 176

Class

KeyvalueMongodb
This class holds a MongoDB key-value backend.

Namespace

Drupal\mongodb

Code

public function set($key, $value) {
  $this
    ->collection()
    ->update(array(
    '_id' => (string) $key,
  ), $this
    ->getObject($key, $value), array(
    'upsert' => TRUE,
  ));
}