deno.land / x / eta@v3.4.0 / src / storage.ts
1234567891011121314151617181920212223242526/** * 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 }; }}
Version Info