LRU(最近最少使用)算法原理及PHP实现( 三 )

this.next = null; // 指向下一个节点

this.prev = null; // 指向前一个节点

}

function LRUCache(capacity) {

var cache = {};

var count = 0;

var capacity;

head = new DLinkedNode();

tail = new DLinkedNode();

tail.prev = head;

head.next = tail;

this.get = function(key) {

var node = cache[key];

if (!node) return null;

this.moveToHead(node);

return node.data;

}

this.set = function(key, data) {

推荐阅读