var p = Cache.prototype p.put = function (key, value) { var entry = this.get(key, true) if (!entry) { this.size++ } this._data[key] = { key: key, value: value } }
p.get = function (key, returnEntry) { var entry = this._data[key] if (entry === undefined) return return returnEntry ? entry : entry.value }
var p = Cache.prototype p.put = function (key, value) { var removed var entry = this.get(key, true) if (!entry) { if (this.size === this.limit) { removed = this.shift() } this._keys.push(key) this.size++ } this._data[key] = { key: key, value: value }
return removed }
p.shift = function () { var head var key = this._keys.shift() if (key !== undefined) { deletethis._data[key] this.size-- } return head }
p.get = function (key, returnEntry) { var entry = this._data[key] if (entry === undefined) return return returnEntry ? entry : entry.value }