code: def upsert(self, doc, namespace, timestamp):
          
  
          # Allow exceptions to be triggered (for testing purposes)
          if doc.get("_upsert_exception"):
              raise Exception("upsert exception")
  
          doc_id = doc["_id"]
          self.doc_dict[doc_id] = Entry(doc=doc, ns=namespace, ts=timestamp)
docs: Adds a document to the doc dict.