r2dbc / r2dbc-pool

Connection Pooling for Reactive Relational Database Connectivity
https://r2dbc.io
Apache License 2.0
332 stars 55 forks source link

#115 Add support for background eviction of idle objects #117

Closed petromir closed 3 years ago

petromir commented 3 years ago

Issue description

https://github.com/r2dbc/r2dbc-pool/issues/115

New Public APIs

A new method has been added as part of ConnectionPoolConfiguration builder

public Builder maxIdleTime(@Nullable Duration maxIdleTime, @Nullable Duration backgroundEvictionInterval) {
     this.maxIdleTime = applyDefault(maxIdleTime);
     this.backgroundEvictionInterval = applyDefault(backgroundEvictionInterval);
     return this;
}

Additional context

Background eviction is enabled by default and it will use maxIdleTime as an interval, unless something else is specified programmatically.

mp911de commented 3 years ago

Thank you for your contribution. That's merged, polished, and backported now.

petromir commented 3 years ago

Thanks! @mp911de I didn't understand why

Setting the value to Duration.ZERO disables background eviction even if maxIdleTime is configured.

mp911de commented 3 years ago

To give users full flexibility and to go out of their way if someone wants to achieve specific functionality. Being a limiting factor for no good reason typically gives users a difficult time.

petromir commented 3 years ago

I missed the context, sorry. It was about this https://github.com/r2dbc/r2dbc-pool/commit/4c7a6ba2a1b29a43b6682bb85c224ef23715c7fb#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R52 Just don't understand the connection between eviction time and acquire retry.

mp911de commented 3 years ago

Good catch, the comment is in the wrong line, need to fix that

mp911de commented 3 years ago

Done.