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

python 做办公网站即墨网站制作

python 做办公网站,即墨网站制作,靖安建设局网站,html制作一个简单美食网页LRU是Last Recent Used 缩写#xff0c;做为一种缓存算法#xff0c;将最近较少使用的缓存失效。memcache采用了该算法。如下采用了一种PHP的实现方式。该算法将每次新增的内容#xff0c;放到缓存顶部#xff0c;达到缓存极限时#xff0c;将缓存底部的内容清除。可以通过…LRU是Last Recent Used 缩写做为一种缓存算法将最近较少使用的缓存失效。memcache采用了该算法。如下采用了一种PHP的实现方式。该算法将每次新增的内容放到缓存顶部达到缓存极限时将缓存底部的内容清除。可以通过如下PHP代码来模拟。 ?php class LRUCache {private $head;private $tail;private $capacity;private $hashmap;public function __construct($capacity) {$this-capacity $capacity;$this-hashmap array();$this-head new Node(null, null);$this-tail new Node(null, null);$this-head-setNext($this-tail);$this-tail-setPrevious($this-head);}public function get($key) {if (!isset($this-hashmap[$key])) { return null; }$node $this-hashmap[$key];if (count($this-hashmap) 1) { return $node-getData(); }// refresh the access$this-detach($node);$this-attach($this-head, $node);return $node-getData();}public function put($key, $data) {if ($this-capacity 0) { return false; }if (isset($this-hashmap[$key]) !empty($this-hashmap[$key])) {$node $this-hashmap[$key];// update data$this-detach($node);$this-attach($this-head, $node);$node-setData($data);}else {$node new Node($key, $data);$this-hashmap[$key] $node;$this-attach($this-head, $node);// check if cache is fullif (count($this-hashmap) $this-capacity) {// were full, remove the tail$nodeToRemove $this-tail-getPrevious();$this-detach($nodeToRemove);unset($this-hashmap[$nodeToRemove-getKey()]);}}return true;}private function attach($head, $node) {$node-setPrevious($head);$node-setNext($head-getNext());$node-getNext()-setPrevious($node);$node-getPrevious()-setNext($node);}private function detach($node) {$node-getPrevious()-setNext($node-getNext());$node-getNext()-setPrevious($node-getPrevious());}}/*** Class that represents a node in a doubly linked list*/ class Node {private $key;// the content of the nodeprivate $data;// the next nodeprivate $next;// the previous nodeprivate $previous;public function __construct($key, $data) {$this-key $key;$this-data $data;}public function setData($data) {$this-data $data;}public function setNext($next) {$this-next $next;}public function setPrevious($previous) {$this-previous $previous;}public function getKey() {return $this-key;}public function getData() {return $this-data;}public function getNext() {return $this-next;}public function getPrevious() {return $this-previous;}}来源 http://it.taocms.org/03/138.htm 来自为知笔记(Wiz) 转载于:https://www.cnblogs.com/phonecom/p/984d230ed46d76bcbc5a35f523b38ffd.html
http://www.pierceye.com/news/351410/

相关文章:

  • 网站备案流程阿里云南宁网站建设官网
  • h5网站制作介绍简单的静态 新闻 asp 网站源码
  • 济南seo网站推广公司帮别人做彩票网站吗
  • 郑州市网站建设怎么样wordpress wp editor
  • 台州网站建设 推广公司网络营销课程总结范文
  • 网站 外包 版权杭州做官网的有哪些公司
  • 微信网站html5中山平面设计公司
  • 建站网站教程视频世界网站排名
  • 做小程序的流程seo 整站优化
  • 网站前台代码国内网站主机
  • 网站后台asp源码高明顺德网站建设
  • 网站建设推广软文网络规划设计师考试全程指导(第2版) pdf
  • 备案网站多少钱支持wordpress的空间
  • 哈尔滨网页模板建站wordpress网页设定
  • 哔哩哔哩网站怎么做视频软件进入公众号会不会泄露个人信息
  • 域名过期做的网站怎么办wap网站前景
  • 网站设计公司 宁波少儿编程课
  • 建设信用卡银行积分商城网站网站关键词优化培训
  • 网站建设对电子商务的意义深圳网站设计兴田德润简介
  • 门设计的网站建设北京最大专业网站建设
  • 黄埔建网站公司长沙 网页制作
  • 网站页面海珠网站建设方案
  • 东宁网站制作公司产品彩页设计
  • 郑州大搜索网站为什么要建立网站
  • 广东网站建设公司排名网页设计模板网站免费
  • 佛山网站建设小程序注册营业执照申请
  • 网站建设文案策划鞍山兼职吧
  • 手机投资网站合肥seo优化排名公司
  • 上海网站制作公司的排名药品网站如何建设
  • 模板网站建设包括哪些wordpress怎么加关键词和描述