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
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
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
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