def url_id_time_list_by_user_id(user_id, limit, offset): id_list = url_id_list_by_user_id(user_id, limit, offset) time_dict = kv.get_multi(id_list, key_prefix=KV_TXT_SAVE_TIME) result = [] for i in map(str, id_list): _time = time_dict.get(i, 0) if not _time: _time = time() kv.set(KV_TXT_SAVE_TIME + i, _time) result.append([i, _time]) return result
def url_id_time_list_by_user_id(user_id, limit, offset): id_list = url_id_list_by_user_id(user_id, limit, offset) time_dict = kv.get_multi(id_list,key_prefix=KV_TXT_SAVE_TIME) result = [] for i in map(str,id_list): _time = time_dict.get(i,0) if not _time: _time = time() kv.set(KV_TXT_SAVE_TIME+i,_time) result.append([i,_time]) return result
def txt_set(id, txt): txt = txt.rstrip() key = KV_TXT+str(id) if txt: return kv.set(key,txt) else: kv.delete(key)
def txt_set(id, txt): txt = txt.rstrip() key = KV_TXT + str(id) if txt: return kv.set(key, txt) else: kv.delete(key)
def txt_save(user_id, url, txt): url_id = url_new(url) txt=txt_rstrip(txt) if not txt: txt_hide(user_id, url_id) txt_old = txt_get(url_id) or '' if txt_old == txt: return mc_txt_brief.delete(url_id) txt_set(url_id, txt_rstrip(txt)) now = int(time.time()) if txt: txt_touch(user_id, url_id) txt_log_save(user_id, url_id, txt, txt_old) kv.set(KV_TXT_SAVE_TIME+str(url_id), now)
def txt_save(user_id, url, txt): url_id = url_new(url) txt = txt_rstrip(txt) if not txt: txt_hide(user_id, url_id) txt_old = txt_get(url_id) or '' if txt_old == txt: return mc_txt_brief.delete(url_id) txt_set(url_id, txt_rstrip(txt)) now = int(time.time()) if txt: txt_touch(user_id, url_id) txt_log_save(user_id, url_id, txt, txt_old) kv.set(KV_TXT_SAVE_TIME + str(url_id), now)
def txt_log_save(user_id, url_id, txt, txt_old): now = int(time.time()) if txt_old and now - txt_log_last_time(url_id) > 600: cursor = connection.cursor() cursor.execute( 'insert into txt_log (url_id, user_id, time) values (%s,%s,%s)' % (url_id, user_id, int(time.time()))) id = cursor.lastrowid kv.set('TxtLog:%s' % id, txt_old) diff = diff_get(txt_old, txt) kv.set('TxtDiff:%s' % id, diff) kv.set(KV_TXT_SAVE_TIME + str(url_id), now)
def txt_log_save(user_id, url_id, txt, txt_old): now = int(time.time()) if txt_old and now - txt_log_last_time(url_id) > 600: cursor = connection.cursor() cursor.execute( 'insert into txt_log (url_id, user_id, time) values (%s,%s,%s)', (url_id, user_id, int(time.time())) ) id = cursor.lastrowid kv.set('TxtLog:%s' % id, txt_old) diff = diff_get(txt_old, txt) kv.set('TxtDiff:%s' % id, diff) kv.set(KV_TXT_SAVE_TIME+str(url_id), now)
def set(id, value): key = "S:%s" % id if value: kv.set(key, value) else: kv.delete(key)
def set(id, value): key = "S:%s"%id if value: kv.set(key, value) else: kv.delete(key)