123456789101112131415161718192021222324252627282930313233 |
- import { isValidTimeout, isServer } from './utils.esm.js';
- class Removable {
- destroy() {
- this.clearGcTimeout();
- }
- scheduleGc() {
- this.clearGcTimeout();
- if (isValidTimeout(this.cacheTime)) {
- this.gcTimeout = setTimeout(() => {
- this.optionalRemove();
- }, this.cacheTime);
- }
- }
- updateCacheTime(newCacheTime) {
- // Default to 5 minutes (Infinity for server-side) if no cache time is set
- this.cacheTime = Math.max(this.cacheTime || 0, newCacheTime != null ? newCacheTime : isServer ? Infinity : 5 * 60 * 1000);
- }
- clearGcTimeout() {
- if (this.gcTimeout) {
- clearTimeout(this.gcTimeout);
- this.gcTimeout = undefined;
- }
- }
- }
- export { Removable };
- //# sourceMappingURL=removable.esm.js.map
|