@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
36 lines (35 loc) • 670 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DataSourceCacheDefault = void 0;
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 = {};
}
}
exports.DataSourceCacheDefault = DataSourceCacheDefault;