coopernurse / node-pool

Generic resource pooling for node.js
2.38k stars 259 forks source link

Add a maximum age of object in pool #303

Open pstonham opened 1 year ago

pstonham commented 1 year ago

Added maxAgeMillis which if set will check the age of an object in the idle and evict if older than the value in MS.

Allows for eviction of old connections even if they've been used recently.

matthieusieben commented 1 year ago

Amazing ! I was just looking for this and had to implement it using the validate()

matthieusieben commented 1 year ago

Note that the effective value for evictionRunIntervalMillis should probably be something like Math.min(evictionRunIntervalMillis, maxAgeMillis) to avoid keeping overage resources alive for too long.