Ejemplo n.º 1
0
def update_nickname_of_user_wrote_contents_cache(user_obj):
    """
    Update nickname of stories, comments, replies cache that user wrote
    Parameter: user object
    """
    if not isinstance(user_obj, Users):
        return None

    story_id_list = api.get_id_list_of_user_wrote_stories(user_obj, None, None)

    for story_id in story_id_list:                               
        redis.update_story_cache(story_id, 'author_nickname', user_obj.nickname) 

    comment_id_list = api.get_id_list_of_user_wrote_comments(user_obj, None, None)

    for comment_id in comment_id_list:
        redis.update_comment_cache(comment_id, 'author_nickname', user_obj.nickname)

    reply_id_list = api.get_id_list_of_user_wrote_replies(user_obj, None, None)

    for reply_id in reply_id_list:
        redis.update_reply_cache(reply_id, 'author_nickname', user_obj.nickname)

    return None
Ejemplo n.º 2
0
def get_replies_from_reply_id_list(reply_id_list):
    """
    Get replies from reply ID list
    Parameter: reply ID list
    """
    if not isinstance(reply_id_list, list):
        return None

    replies = []

    for reply_id in reply_id_list:
        reply = cache.get("reply:" + str(reply_id))

        if reply == None:
            reply = redis.update_reply_cache(reply_id)

        replies.append(reply)

    return replies