4 * Copyright(c) 2011 Sencha Inc.
12 module.exports = Cache;
17 * @param {Number} limit
21 function Cache(limit) {
28 * Touch `key`, promoting the object.
35 Cache.prototype.touch = function(key, i){
36 this.keys.splice(i,1);
47 Cache.prototype.remove = function(key){
48 delete this.store[key];
52 * Get the object stored for `key`.
59 Cache.prototype.get = function(key){
60 return this.store[key];
71 Cache.prototype.add = function(key){
73 var len = this.keys.push(key);
75 // limit reached, invalidate LRU
76 if (len > this.limit) this.remove(this.keys.shift());
78 var arr = this.store[key] = [];
79 arr.createdAt = new Date;