[Illustration] algorithm - Web Cache

"""网页缓存"""
cache = {} # 缓存

def get_page(url):
    if cache.get(url): # 如果网页在缓存中
        return cache[url]
    else:
        data = get_data_from_serve(url) # 从服务器获取网页
        cache[url] = data # 先将数据保存到缓存中
        return data
Published 165 original articles · won praise 30 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44478378/article/details/104448334