MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / GeneratedCacheAdapter

Class GeneratedCacheAdapter

packages/core/src/cache/GeneratedCacheAdapter.ts:5–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4/** Cache adapter backed by pre-generated static data, typically produced by the CLI cache:generate command. */
5export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected