public static Jedis createJedis(RedisClientProfile profile) { Jedis jedis = new Jedis(profile.getHostaddress(), profile.getPort()); jedis.connect(); try { // jedis.getClient().setTimeoutInfinite(); jedis .getClient() .getSocket() .setKeepAlive(true); // keep alive, with time out set to 2 seconds // jedis.getClient().getSocket().setSoTimeout(50); // jedis.getClient().setTimeout(5); } catch (Exception e) { throw new BackendRuntimeException( BackendRuntimeException.InternalServerError, "error creating jedis connection " + profile.toString(), e); } jedis.select(profile.getDatabaseIndex()); return jedis; }