DefaultEvictor.js 465 B

1234567891011121314151617181920212223
  1. "use strict";
  2. class DefaultEvictor {
  3. evict(config, pooledResource, availableObjectsCount) {
  4. const idleTime = Date.now() - pooledResource.lastIdleTime;
  5. if (
  6. config.softIdleTimeoutMillis > 0 &&
  7. config.softIdleTimeoutMillis < idleTime &&
  8. config.min < availableObjectsCount
  9. ) {
  10. return true;
  11. }
  12. if (config.idleTimeoutMillis < idleTime) {
  13. return true;
  14. }
  15. return false;
  16. }
  17. }
  18. module.exports = DefaultEvictor;