UNPKG

@mui/x-tree-view

Version:

The community edition of the MUI X Tree View components.

29 lines 499 B
export class DataSourceCacheDefault { constructor({ ttl = 300_000 }) { this.cache = {}; this.ttl = ttl; } set(key, value) { const expiry = Date.now() + this.ttl; this.cache[key] = { value, expiry }; } get(key) { const entry = this.cache[key]; if (!entry) { return undefined; } if (Date.now() > entry.expiry) { delete this.cache[key]; return -1; } return entry.value; } clear() { this.cache = {}; } }