fchat-rising/learn/async-cache.ts

19 lines
436 B
TypeScript
Raw Permalink Normal View History

import { Cache, CacheCollection } from './cache';
export abstract class AsyncCache<RecordType> {
protected cache: CacheCollection<RecordType> = {};
abstract get(name: string): Promise<RecordType | null>;
// tslint:disable-next-line no-any
abstract register(record: any): void;
static nameKey(name: string): string {
return Cache.nameKey(name);
}
2021-03-21 21:28:13 +00:00
clear(): void {
this.cache = {};
}
}