def cached_top_asns(request): """See :class:`bgpranking.api.cache_get_top_asns`""" cached_dates = bgpranking.cache_get_dates() date = request.get('date') if date is None or date in cached_dates: return json.dumps(bgpranking.cache_get_top_asns( request.get('source'), date, request.get('limit'), request.get('with_sources')), cls=SetEncoder) return json.dumps({})
def cached_position(request): """See :class:`bgpranking.api.cache_get_position`""" asn = request.get('asn') if asn is None: return json.dumps({}) cached_dates = bgpranking.cache_get_dates() date = request.get('date') if date is None or date in cached_dates: return json.dumps(bgpranking.cache_get_position(asn, date=date), cls=SetEncoder) return json.dumps({})
def cached_daily_rank(request): """See :class:`bgpranking.api.cache_get_daily_rank`""" asn = request.get('asn') if asn is None: return json.dumps({}) cached_dates = bgpranking.cache_get_dates() date = request.get('date') if date is None or date in cached_dates: return json.dumps(bgpranking.cache_get_daily_rank(asn, request.get('sources'), date)) return json.dumps({})
def cached_dates(request): """See :class:`bgpranking.api.cache_get_dates`""" return json.dumps(bgpranking.cache_get_dates())