Пример #1
0
def get_posts(keyword):
    memc = ac_core.get_memc()
    posts = memc.get("search_posts_"+base64.standard_b64encode(keyword))
    if posts:
        return print_posts(posts)
    
    posts = find_posts(keyword)
    if not posts:
        return 'NO RELATED POSTS!'

    memc.set("search_posts_"+base64.standard_b64encode(keyword), posts, 3600)
    return print_posts(posts)
Пример #2
0
def get_cloud(keyword, date = 7):
    memc = ac_core.get_memc()
    tags = memc.get("tag_cloud_"+keyword)
    posts = memc.get("posts_cloud_"+keyword)
    if tags and posts:
        return print_cloud(tags, keywordi, date)
    
    tags = get_tags(keyword, date)
    posts = get_posts(keyword, date)
    if not tags:
        return 'NO RELATED TAGS!'

    memc.set("post_cloud_"+keyword, posts, 3600)
    memc.set("tag_cloud_"+keyword, tags, 3600)
    return print_cloud(tags, posts, date)