예제 #1
0
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
예제 #2
0
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 
예제 #3
0
def txt_set(id, txt):
    txt = txt.rstrip()
    key = KV_TXT+str(id)
    if txt:
        return kv.set(key,txt)   
    else:
        kv.delete(key)
예제 #4
0
def txt_set(id, txt):
    txt = txt.rstrip()
    key = KV_TXT + str(id)
    if txt:
        return kv.set(key, txt)
    else:
        kv.delete(key)
예제 #5
0
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) 
예제 #6
0
파일: index.py 프로젝트: s6dyl/42qu-notepad
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)
예제 #7
0
파일: index.py 프로젝트: s6dyl/42qu-notepad
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)
예제 #8
0
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)
예제 #9
0
 def set(id, value):
     key = "S:%s" % id
     if value:
         kv.set(key, value)
     else:
         kv.delete(key)
예제 #10
0
 def set(id, value):
     key = "S:%s"%id
     if value: 
         kv.set(key, value)
     else:
         kv.delete(key)