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
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
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
def on_shutdown(): self.keep_running = False get_redis().publish("twisted.shutdown", 1)
def document_diff(name=None, revision=None): if revision == None: revision = 0 doc = DocumentInfo(get_redis(), name) diff = doc.get_diff(revision) return diff
def document_get(name): doc = DocumentInfo(get_redis(), name) r = {"data": doc.get_data(), "revision": doc.get_revision()} return r