feat: async cache.read()/write(), remove .has()

This commit is contained in:
harttle
2020-03-05 01:47:53 +08:00
parent 65b849c02a
commit 61dac49b04
4 changed files with 26 additions and 10 deletions
+2 -3
View File
@@ -1,5 +1,4 @@
export interface Cache<T> {
write (key: string, value: T): void;
read (key: string): T | undefined;
has (key: string): boolean;
write (key: string, value: T): void | Promise<void>;
read (key: string): T | undefined | Promise<T | undefined>;
}
-4
View File
@@ -42,10 +42,6 @@ export class LRU<T> implements Cache<T> {
return value
}
has (key: string): boolean {
return !!this.cache[key]
}
remove (key: string) {
const node = this.cache[key]
node.prev.next = node.next