示例#1
0
文件: api.py 项目: avaleske/istayon
def get_like_data_through_cache():
    packed_values = swrcache.get(settings.LIKED_INFO_KEY)
    if not packed_values:
        log.info("liked_info cache miss")
        packed_values = __get_like_data()
        swrcache.set(settings.LIKED_INFO_KEY, packed_values, timeout=60)
    return packed_values
示例#2
0
def get_like_data_through_cache():
    packed_values = swrcache.get(settings.LIKED_INFO_KEY)
    if not packed_values:
        log.info("liked_info cache miss")
        packed_values = __get_like_data()
        swrcache.set(settings.LIKED_INFO_KEY, packed_values, timeout=60)
    return packed_values
示例#3
0
def __get_avatar_url(blog_name, size=16):
    cache_key = blog_name + "_AVATAR"
    avatar = swrcache.get(cache_key)
    if not avatar:
        try:
            client = pytumblr.TumblrRestClient(settings.TUMBLR_API_KEY)
            avatar = client.avatar(blog_name, size=size)["avatar_url"]
        except ServerNotFoundError:
            avatar = None
        swrcache.set(cache_key, avatar, 60 * 60)
    return avatar
示例#4
0
文件: api.py 项目: avaleske/istayon
def __get_avatar_url(blog_name, size=16):
    cache_key = blog_name + '_AVATAR'
    avatar = swrcache.get(cache_key)
    if not avatar:
        try:
            client = pytumblr.TumblrRestClient(settings.TUMBLR_API_KEY)
            response = client.avatar(blog_name, size=size)['response'];
            avatar = response['avatar_url']
        except (ServerNotFoundError, KeyError) as e:
            avatar = None
        swrcache.set(cache_key, avatar, 60 * 60)
    return avatar
示例#5
0
def __get_avatar_url(blog_name, size=16):
    cache_key = blog_name + '_AVATAR'
    avatar = swrcache.get(cache_key)
    if not avatar:
        try:
            client = pytumblr.TumblrRestClient(settings.TUMBLR_API_KEY)
            response = client.avatar(blog_name, size=size)['response']
            avatar = response['avatar_url']
        except (ServerNotFoundError, KeyError) as e:
            avatar = None
        swrcache.set(cache_key, avatar, 60 * 60)
    return avatar