You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -51,11 +48,11 @@ export class Cache<T> implements CacheInterface<T> {
51
48
/**
52
49
* Creates an instance of Cache.
53
50
* @param defaultValidityTime - The default validity time in milliseconds. Use 0 for unlimited cache duration.
54
-
* @parammaxSize - The maximum number of entries in the cache. Use Infinity for unlimited size. Items are evicted based on a least recently used (LRU) strategy.
51
+
* @paramcapacity - The maximum number of entries in the cache. Use Infinity for unlimited size. Items are evicted based on a least recently used (LRU) strategy.
55
52
*/
56
53
constructor(
57
54
privatedefaultValidityTime: number,
58
-
privatemaxSize=Infinity
55
+
privatecapacity=Infinity
59
56
){
60
57
this.cache=newMap<string,CacheEntry<T>>();
61
58
}
@@ -91,14 +88,14 @@ export class Cache<T> implements CacheInterface<T> {
91
88
}
92
89
93
90
if(isExpired(entry)){
94
-
this.cache.delete(key!);
91
+
this.cache.delete(key);
95
92
returnundefined;
96
93
}
97
94
98
95
// LRU cache: Move accessed entry to the end of the Map to mark it as recently used
99
-
if(this.maxSize!==Infinity){
100
-
this.cache.delete(key!);
101
-
this.cache.set(key!,entry);
96
+
if(this.capacity!==Infinity){
97
+
this.cache.delete(key);
98
+
this.cache.set(key,entry);
102
99
}
103
100
returnentry?.entry;
104
101
}
@@ -113,15 +110,15 @@ export class Cache<T> implements CacheInterface<T> {
0 commit comments