Skip to content

Commit

Permalink
wip(LRUCache): 更新 reason 的类型
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Aug 1, 2024
1 parent 8112316 commit 6b5a6ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/lib/LRUCache.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @see https://www.npmjs.com/package/lru-cache

type DisposeReason = 'set' | 'delete' | 'evict' | 'expired';
export interface LRUCacheOptions<K = string, V = unknown> {
/** The maximum number of items that remain in the cache. default 500 */
max?: number;
/** how long to live in ms. default 0 */
ttl?: number;
updateAgeOnGet?: boolean;
/** Function that is called on items when they are dropped from the cache */
dispose?(val: LRUCacheItem<V>, key: K, reason: string): void;
dispose?(val: LRUCacheItem<V>, key: K, reason: DisposeReason): void;
}

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

0 comments on commit 6b5a6ce

Please sign in to comment.