Skip to content

Commit

Permalink
feat: LRU cache with time-to-keep Expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
mrflip committed Aug 8, 2022
1 parent afade3a commit d279848
Show file tree
Hide file tree
Showing 10 changed files with 888 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {default as KDTree} from './kd-tree';
export {default as LinkedList} from './linked-list';
export {default as LRUCache} from './lru-cache';
export {default as LRUCacheWithDelete} from './lru-cache-with-delete';
export {default as LRUCacheWithExpiry} from './lru-cache-with-expiry';
export {default as LRUMap} from './lru-map';
export {default as LRUMapWithDelete} from './lru-map-with-delete';
export {default as MultiMap} from './multi-map';
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
LinkedList: require('./linked-list.js'),
LRUCache: require('./lru-cache.js'),
LRUCacheWithDelete: require('./lru-cache-with-delete.js'),
LRUCacheWithExpiry: require('./lru-cache-with-expiry.js'),
LRUMap: require('./lru-map.js'),
LRUMapWithDelete: require('./lru-map-with-delete.js'),
MultiMap: require('./multi-map.js'),
Expand Down
24 changes: 24 additions & 0 deletions lru-cache-with-expiry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Mnemonist LRUCacheWithExpiry Typings
* =====================================
*/
import LRUCacheWithDelete from './lru-cache-with-delete';

export interface Logger {
trace(message: string, story: any): void
debug(message: string, story: any): void
info(message: string, story: any): void
warn(message: string, story: any): void
error(message: string, story: any): void
}

export default class LRUCacheWithExpiry<K, V> extends LRUCacheWithDelete<K, V> {

expire(): void;

monitor(interval: number, options: {
logger: Logger,
didError: (err: Error, inst: LRUCacheWithExpiry<K, V>) => boolean,
didExpire: (inst: LRUCacheWithExpiry<K, V>, begT: number) => void,
}): void;
}
Loading

0 comments on commit d279848

Please sign in to comment.