Exemplo n.º 1
0
 def __translate_to_json_document(self, key, value, ttl=0):
     try:
         if type(value) != dict:
             value = json.loads(value)
         js = JsonObject.create()
         for field, val in value.items():
             js.put(field, val)
         doc = JsonDocument.create(key, ttl, js)
         return doc
     except DocumentNotJsonException as e:
         return StringDocument.create(key, str(value))
     except Exception as e:
         return StringDocument.create(key, str(value))
     except:
         pass
     return StringDocument.create(key, str(value))
Exemplo n.º 2
0
 def insert_string_document(self, keys):
     for key in keys:
         self.cb.upsert(StringDocument.create(key,
                                              '{value":"' + key + '"}'))