public static < V > V doWorkInPool ( final Pool < Jedis > pool , final PoolWork < Jedis , V > work ) throws Exception { if ( pool == null ) { throw new IllegalArgumentException ( "pool must not be null" ) ; } if ( work == null ) { throw new IllegalArgumentException ( "work must not be null" ) ; } final V result ; final Jedis poolResource = pool . getResource ( ) ; try { result = work . doWork ( poolResource ) ; } finally { poolResource . close ( ) ; } return result ; }
Perform the given work with a Jedis connection from the given pool .