(key: string)
| 101 | } |
| 102 | |
| 103 | override async getInternal(key: string): Promise<GetResult> { |
| 104 | const cached = this.cache.get(key); |
| 105 | if (!cached) return {hit: false}; |
| 106 | |
| 107 | try { |
| 108 | const data = await fs.promises.readFile(cached.path); |
| 109 | return {hit: true, data: data}; |
| 110 | } catch (err) { |
| 111 | logger.error(`error reading '${key}' from disk cache: `, err); |
| 112 | return {hit: false}; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | async putInternal(key: string, value: Buffer): Promise<void> { |
| 117 | const info = { |