Exemplo n.º 1
0
 def save_sentences_on_hashkey(self,key,sent):
     try:
         client = get_redis()
         client.lpush(key, json.dumps(sent))
         return 1
     except Exception as e:
         log_exception("Exception in storing sentence data on redis store | Cause: " + str(e), AppContext.getContext(), e)
         return None
Exemplo n.º 2
0
 def get_sentence_by_keys(self, keys):
     try:
         client = get_redis()
         result = []
         for key in keys:
             val = client.get(key)
             if val:
                 result.append(json.loads(val))
         return result
     except Exception as e:
         log_exception(
             "Exception in fetching sentences from redis store  | Cause: " +
             str(e), None, e)
         return None
Exemplo n.º 3
0
 def get_sentence_by_keys(self,keys):
     try:
         client = get_redis()
         result = []
         for key in keys:
             sent_obj={}
             val=client.lrange(key, 0, -1)
             sent_obj["key"]=key
             sent_obj["value"]=val
             result.append(sent_obj)
         return result
     except Exception as e:
         log_exception("Exception in fetching sentences from redis store  | Cause: " + str(e), None, e)
         return None
Exemplo n.º 4
0
 def on_shutdown():
     self.keep_running = False
     get_redis().publish("twisted.shutdown", 1)
Exemplo n.º 5
0
 def document_diff(name=None, revision=None):
     if revision == None:
         revision = 0
     doc = DocumentInfo(get_redis(), name)
     diff = doc.get_diff(revision)
     return diff
Exemplo n.º 6
0
 def document_get(name):
     doc = DocumentInfo(get_redis(), name)
     r = {"data": doc.get_data(), "revision": doc.get_revision()}
     return r
Exemplo n.º 7
0
 def on_shutdown():
     self.keep_running = False
     get_redis().publish("twisted.shutdown", 1)
Exemplo n.º 8
0
 def document_diff(name=None, revision=None):
     if revision == None: revision = 0
     doc = DocumentInfo(get_redis(), name)
     diff = doc.get_diff(revision)
     return diff
Exemplo n.º 9
0
 def document_get(name):
     doc = DocumentInfo(get_redis(), name)
     r = {"data": doc.get_data(), "revision": doc.get_revision()}
     return r