Skip to content

Commit 6b5a6ce

Browse files
committed
wip(LRUCache): 更新 reason 的类型
1 parent 8112316 commit 6b5a6ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/common/lib/LRUCache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// @see https://www.npmjs.com/package/lru-cache
2-
2+
type DisposeReason = 'set' | 'delete' | 'evict' | 'expired';
33
export interface LRUCacheOptions<K = string, V = unknown> {
44
/** The maximum number of items that remain in the cache. default 500 */
55
max?: number;
66
/** how long to live in ms. default 0 */
77
ttl?: number;
88
updateAgeOnGet?: boolean;
99
/** Function that is called on items when they are dropped from the cache */
10-
dispose?(val: LRUCacheItem<V>, key: K, reason: string): void;
10+
dispose?(val: LRUCacheItem<V>, key: K, reason: DisposeReason): void;
1111
}
1212

1313
interface LRUCacheItem<V> {
@@ -65,7 +65,7 @@ export class LRUCache<K = string, V = unknown> {
6565
return value.v as T;
6666
}
6767
/** Deletes a key out of the cache */
68-
delete(key: K, reason = 'delete') {
68+
delete(key: K, reason: DisposeReason = 'delete') {
6969
if (!this.cache.has(key)) return false;
7070
const val = this.cache.get(key);
7171
this.cache.delete(key);

0 commit comments

Comments
 (0)