12345678910111213141516171819202122232425262728293031323334353637 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- var utils = require('./utils.js');
- class Removable {
- destroy() {
- this.clearGcTimeout();
- }
- scheduleGc() {
- this.clearGcTimeout();
- if (utils.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 : utils.isServer ? Infinity : 5 * 60 * 1000);
- }
- clearGcTimeout() {
- if (this.gcTimeout) {
- clearTimeout(this.gcTimeout);
- this.gcTimeout = undefined;
- }
- }
- }
- exports.Removable = Removable;
- //# sourceMappingURL=removable.js.map
|