/* ======================================== LRU 最近最少使用 ======================================== */ function FifoCache(limit){ limit = limit||10; var _store = []; var index = {}; this.get = function(key){ var ind = index[key]; return _store[ind]; }; this.set = function(key,value){ if(_store.length>=limit){ _store.shift(); for(var k in index){ index[k] = index[k]-1; } } var length = _store.push(value); index[key] = length-1; }; this.list = function(){ console.log(_store); }; }