UNPKG

@mui/x-tree-view

Version:

The community edition of the MUI X Tree View components.

31 lines 547 B
export class DataSourceCacheDefault { constructor({ ttl = 300_000 }) { this.cache = void 0; this.ttl = void 0; 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 = {}; } }