[ 
https://issues.apache.org/jira/browse/POOL-390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17246147#comment-17246147
 ] 

Phil Steitz commented on POOL-390:
----------------------------------

Looks like a useful feature to me .  DBCP does this in its object factory, 
PoolableConnectionFactory.  Assuming you are extending BasePooledObjectFactory 
and using DefaultPooledObjects in the pool, the creation time is tracked and 
you can just check it for max age in the factory's activation method.  See 
o.a.c.dbcp2.PoolableConnectionFactory#activateObject for a way to do this with 
pool2 as is.

The pool enhancement that might make sense is to either add a maxLifetime 
property to BasePooledObjectFactory and have the default activateObject impl do 
what DBCP's pcf does or just make maxLifetime a GOP/GKOP property and have 
borrow and return operations do the checks (DBCP2 BasePooledObject exposes 
createTime).  The second is probably easier for users and also allows a little 
better control.

> Add a max age to pool entries
> -----------------------------
>
>                 Key: POOL-390
>                 URL: https://issues.apache.org/jira/browse/POOL-390
>             Project: Commons Pool
>          Issue Type: Improvement
>            Reporter: reggie
>            Priority: Minor
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> It would be nice if pool2 allowed configuration of a "max-age" parameter on a 
> pool entry. When this is set, at checkout time, if the max age is exceeded, 
> this entry would be discarded. It would be nice to do this instead of an 
> evictor thread in cases where pool access may be very sporadic. The evictor 
> thread model could run many times and do nothing.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to