Skip to content

Commit ffc0c59

Browse files
Added Expiring LRU Cache implementation
1 parent d0093fb commit ffc0c59

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cache/lru-cache.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ExpiringLRUCache, LRUCache} from './lru-cache';
1+
import { ExpiringLRUCache, LRUCache } from './lru-cache';
22

33
describe('LRUCache', () => {
44
let cache: LRUCache;

src/cache/lru-cache.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ export class LRUCache implements Map<string, string> {
9797
return this;
9898
}
9999
}
100-
100+
/**
101+
* Variation of LRUCache that expires after set time in milliseconds
102+
* @param {number} maxSize - Maximum cache size
103+
* @param {number} timeout - Time in milliseconds after which cache entry will evict itself
104+
**/
101105
export class ExpiringLRUCache extends LRUCache {
102106
constructor(readonly maxSize: number, readonly timeout: number) {
103107
super(maxSize);

0 commit comments

Comments
 (0)