Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends RuntimeExceptio\RuntimeException
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     KeyUtil::validate($key);
     $serialized = $this->serialize->__invoke($value);
     try {
         $this->collection->replaceOne(array('_id' => $key), array('_id' => $key, 'value' => $serialized), array('upsert' => true));
     } catch (UnexpectedValueException $e) {
         throw UnsupportedValueException::forType('binary', $this, 0, $e);
     } catch (Exception $e) {
         throw WriteException::forException($e);
     }
 }
 private function save($data)
 {
     try {
         $this->encoder->encodeFile($data, $this->path);
     } catch (EncodingFailedException $e) {
         if (JSON_ERROR_UTF8 === $e->getCode()) {
             throw UnsupportedValueException::forType('binary', $this);
         }
         throw new WriteException($e->getMessage(), 0, $e);
     } catch (IOException $e) {
         throw new WriteException($e->getMessage(), 0, $e);
     }
 }