UNPKG

@mui/x-data-grid-pro

Version:

The Pro plan edition of the Data Grid components (MUI X).

36 lines 807 B
export function getKey(params) { return JSON.stringify([params.paginationModel, params.filterModel, params.sortModel, params.groupKeys, params.groupFields]); } export class GridDataSourceCacheDefault { constructor({ ttl = 300000 }) { this.cache = void 0; this.ttl = void 0; this.cache = {}; this.ttl = ttl; } set(key, value) { const keyString = getKey(key); const expiry = Date.now() + this.ttl; this.cache[keyString] = { value, expiry }; } get(key) { const keyString = getKey(key); const entry = this.cache[keyString]; if (!entry) { return undefined; } if (Date.now() > entry.expiry) { delete this.cache[keyString]; return undefined; } return entry.value; } clear() { this.cache = {}; } }