| 3 | |
| 4 | /** Cache adapter backed by pre-generated static data, typically produced by the CLI cache:generate command. */ |
| 5 | export class GeneratedCacheAdapter implements CacheAdapter { |
| 6 | readonly #data: Map<string, { data: Dictionary }>; |
| 7 | |
| 8 | constructor(options: { data: Dictionary }) { |
| 9 | this.#data = new Map(Object.entries(options.data)); |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * @inheritDoc |
| 14 | */ |
| 15 | get<T = any>(name: string): T | undefined { |
| 16 | const key = name.replace(/\.[jt]s$/, ''); |
| 17 | const data = this.#data.get(key); |
| 18 | |
| 19 | return data as T; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @inheritDoc |
| 24 | */ |
| 25 | set(name: string, data: any, origin: string): void { |
| 26 | this.#data.set(name, { data }); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @inheritDoc |
| 31 | */ |
| 32 | remove(name: string): void { |
| 33 | this.#data.delete(name); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @inheritDoc |
| 38 | */ |
| 39 | clear(): void { |
| 40 | this.#data.clear(); |
| 41 | } |
| 42 | } |
nothing calls this directly
no outgoing calls
no test coverage detected