Пример #1
0
def update_gdata_keyword(key):
    word_list = [
        kw.split(':')[0].decode('utf8')
        for kw in KeywordInfo.r_keyword.lrange(key, 0, -1)
    ]
    KeywordInfo.update_gdata(word_list)
    return len(word_list)
Пример #2
0
def update_new_keyword(key):
    '''
    .将新加入到词库的关键词刷新到词库
    '''
    insert_list = []
    word_list = [
        kw.decode('utf8') for kw in KeywordInfo.r_nkeyword.lrange(key, 0, -1)
    ]
    result_list = KeywordInfo.update_gdata(word_list)
    KeywordInfo.load_redis_cat_new_word(result_list)
    for word in word_list:
        insert_list.append(word + ':' + RedisKeyManager.get_sort_word(word))
    key_keyword_list = RedisKeyManager.get_keyword_list_key(
        KeywordInfo.KEYWORD_ALIAS)
    RedisKeyManager.redis_lpush(KeywordInfo.r_keyword, key_keyword_list,
                                insert_list)
    RedisKeyManager.clear_single_keyword_list(key,
                                              KeywordInfo.NEWKEYWORD_ALIAS,
                                              KeywordInfo.NEW_KW_LIST_PREV_KEY)
    return len(word_list)