public static JedisPool newJedisPool(String hostAndPort, String password, int db,
            long timeoutMs) {
        final int maxTotal = Runtime.getRuntime().availableProcessors();
        final int maxIdle = maxTotal / 2;

        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(maxTotal);
        poolConfig.setMinIdle(1);
        poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
        poolConfig.setMaxWaitMillis(timeoutMs + 1000);
        // poolConfig.setTestOnBorrow(true);
        poolConfig.setTestWhileIdle(true);

        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        JedisPool jedisPool = new JedisPool(poolConfig, host, port, (int) timeoutMs, password, db);
        return jedisPool;
    }
public static JedisPool newJedisPool(String hostAndPort, String password, int db,
            long timeoutMs) {
        final int maxTotal = Runtime.getRuntime().availableProcessors();
        final int maxIdle = maxTotal / 2;

        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(maxTotal);
        poolConfig.setMinIdle(1);
        poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
        poolConfig.setMaxWaitMillis(timeoutMs + 1000);
        
        poolConfig.setTestWhileIdle(true);

        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        JedisPool jedisPool = new JedisPool(poolConfig, host, port, (int) timeoutMs, password, db);
        return jedisPool;
    }
public static JedisPool newJedisPool ( String hostAndPort , String password , int db , long timeoutMs ) { final int maxTotal = Runtime . getRuntime ( ) . availableProcessors ( ) ; final int maxIdle = maxTotal / 2 ; JedisPoolConfig poolConfig = new JedisPoolConfig ( ) ; poolConfig . setMaxTotal ( maxTotal ) ; poolConfig . setMinIdle ( 1 ) ; poolConfig . setMaxIdle ( maxIdle > 0 ? maxIdle : 1 ) ; poolConfig . setMaxWaitMillis ( timeoutMs + 1000 ) ; // poolConfig.setTestOnBorrow(true); poolConfig . setTestWhileIdle ( true ) ; String [ ] tokens = hostAndPort . split ( ":" ) ; String host = tokens . length > 0 ? tokens [ 0 ] : Protocol . DEFAULT_HOST ; int port = tokens . length > 1 ? Integer . parseInt ( tokens [ 1 ] ) : Protocol . DEFAULT_PORT ; JedisPool jedisPool = new JedisPool ( poolConfig , host , port , ( int ) timeoutMs , password , db ) ; return jedisPool ; }
Creates a new {@link JedisPool}.

@param hostAndPort
@param password
@param db
@param timeoutMs
@return
Creates a new { @link JedisPool } .