当前位置: 首页 > news >正文

西安市城乡建设档案馆网站如何创建一个自己的网站

西安市城乡建设档案馆网站,如何创建一个自己的网站,北京网站建设问问q778925409霸屏,网站建设总体需求分析约束和假设 我们正在缓存什么? 我们正在缓存Web Query的结果我们可以假设输入是有效的,还是需要对其验证? 假设输入是有效的我们可以假设它适应内存吗? 对 编码实现 class Node(object):def __init__(self, results):self.res…

约束和假设

  • 我们正在缓存什么?
    我们正在缓存Web Query的结果
  • 我们可以假设输入是有效的,还是需要对其验证?
    假设输入是有效的
  • 我们可以假设它适应内存吗?

编码实现

class Node(object):def __init__(self, results):self.results = resultsself.prev = Noneself.next = Noneclass LinkedList(object):del __init__(self):self.head = Noneself.tail = Nonedef move_to_front(self, node): # ...def append_to_front(self, node): # ...def remove_from_tail(self): # ...class Cache(obejct):def __init__(self, MAX_SIZE):self.MAX_SIZE = MAX_SIZEself.size = 0self.lookup = {}self.linked_list = LinkedList()def get(self, query)'''Get the stored query result from the cacheAccsssing a node updates its position to the front of the LRU list'''node = self.lookup.get(query)if node is None:return Noneself.linked_list.move_to_front(node)return node.resultsdef set(self, resuts, query):'''Set the results for the given query key in the cache.When updating an entry, updates its position to the front of the LRU listIf the entry is new and the cache is at capacity, remove the oldest entry before the new entry is added '''node = self.lookup.get(query)if node is not None:	node.results = resultsself.linked_list.move_to_front(node)else:if self.size == self.MAX_SIZEself.lookup.pop(self.linked_list.tail.query, None)self.linked_list.remove_from_tail()else:self.size += 1new_node = Node(results)self.linked_list.append_to_front(new_node)self.lookup[query] = new_node
http://www.hkea.cn/news/396182/

相关文章:

  • 汉川网站建设sem代运营
  • 装酷网装修平台东莞seo外包
  • 专门做图片的网站吗如何建网站要什么条件
  • 卢氏县住房和城乡建设局网站站长统计 站长统计
  • 济南 网站制作旺道营销软件
  • 新上线网站如何做搜索引擎站长素材网站
  • 做网站编辑深圳疫情防控最新消息
  • PHP网站开发项目式教程google下载手机版
  • 国外专门用于做网站图片的做网站要多少钱
  • 网站维护费用计入什么科目媒介星软文平台官网
  • 网站建设seo 视频做网站哪个平台好
  • 旅行社网站建设方案论文百度seo公司
  • 长沙网站建设与维护百度开户联系方式
  • 做pcr查基因序列的网站南京百度网站快速优化
  • 数据服务网站策划方案关键词快速优化排名软件
  • 响应式网站缺点学大教育培训机构电话
  • 江苏天德建设工程有限公司网站一个平台怎么推广
  • 石家庄做网络推广的网站推广平台收费标准
  • 贵阳天柱网站建设招聘域名注册平台有哪些
  • 网站建设电话营销百度问一问官网
  • 网站优化建设河南怎么关闭seo综合查询
  • 自贡做响应式网站开发公司google搜索引擎入口google
  • 东莞哪种网站推广好微信朋友圈推广文案
  • 现在学做网站赚钱吗东莞市优速网络科技有限公司
  • 宁津做网站公司宣传推广图片
  • 陕西的建设厅官方网站数据分析报告
  • 企业网站建设的定位互联网
  • 注册域名之后如何做网站优化清理大师
  • wordpress+在线播放推广seo网站
  • 丽水网站建设明恩玉杰网站开发框架