deno.land / x / eta@v3.4.0 / src / storage.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** * Handles storage and accessing of values * * In this case, we use it to store compiled template functions * Indexed by their `name` or `filename` */
export class Cacher<T> { constructor(private cache: Record<string, T>) {} define(key: string, val: T): void { this.cache[key] = val; } get(key: string): T { return this.cache[key]; } remove(key: string): void { delete this.cache[key]; } reset(): void { this.cache = {}; } load(cacheObj: Record<string, T>): void { this.cache = { ...this.cache, ...cacheObj }; }}
eta

Version Info

Tagged at
2 months ago