fix: production build
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
export class LRUCache {
|
||||
constructor(maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
this.map = new Map();
|
||||
this.keys = [];
|
||||
this.maxSize = maxSize
|
||||
this.map = new Map()
|
||||
this.keys = []
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.map.clear();
|
||||
this.map.clear()
|
||||
}
|
||||
|
||||
has(k) {
|
||||
return this.map.has(k);
|
||||
return this.map.has(k)
|
||||
}
|
||||
|
||||
get(k) {
|
||||
const v = this.map.get(k);
|
||||
const v = this.map.get(k)
|
||||
|
||||
if (v !== undefined) {
|
||||
this.keys.push(k);
|
||||
this.keys.push(k)
|
||||
|
||||
if (this.keys.length > this.maxSize * 2) {
|
||||
this.keys.splice(-this.maxSize);
|
||||
this.keys.splice(-this.maxSize)
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
return v
|
||||
}
|
||||
|
||||
set(k, v) {
|
||||
this.map.set(k, v);
|
||||
this.keys.push(k);
|
||||
this.map.set(k, v)
|
||||
this.keys.push(k)
|
||||
|
||||
if (this.map.size > this.maxSize) {
|
||||
this.map.delete(this.keys.shift());
|
||||
this.map.delete(this.keys.shift())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user