UNPKG

@trlogic/tracker-web

Version:
27 lines (26 loc) 1.11 kB
import { ConfigItem } from "src/core/model/TrackerConfig"; import { TrackerVariableType } from "src/core/model/TrackerVariableType"; import { CacheStrategy } from "src/core/model/VariableCollectionMetadata"; import { BaseDataCollector } from "./BaseDataCollector"; /** * Collector with TTL-based caching. * Mirrors Android CachedDataCollector. * * Each variable can have a different cache strategy (FAST: 10s, MEDIUM: 1min, SLOW: 5min, HEAVY: session). * If the cached value is still fresh, the supplier is not called. */ export declare abstract class CachedDataCollector extends BaseDataCollector { private cache; /** * Collect with caching: only re-evaluate if cache has expired. */ protected collectWithCache(data: Map<TrackerVariableType, unknown>, variableType: TrackerVariableType, strategy: CacheStrategy, supplier: () => unknown, configs?: ConfigItem[]): void; /** * Invalidate a specific cached variable. */ protected invalidateCache(variableType: TrackerVariableType): void; /** * Clear all cached values. */ protected clearCache(): void; }