2019-07-08 19:08:16 +00:00
|
|
|
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 = {};
|
|
|
|
}
|
2019-07-08 19:08:16 +00:00
|
|
|
}
|