diff --git a/src/main/java/com/redislabs/redistimeseries/RedisTimeSeries.java b/src/main/java/com/redislabs/redistimeseries/RedisTimeSeries.java index 81524ea..9467ca0 100644 --- a/src/main/java/com/redislabs/redistimeseries/RedisTimeSeries.java +++ b/src/main/java/com/redislabs/redistimeseries/RedisTimeSeries.java @@ -23,6 +23,10 @@ public RedisTimeSeries() { this("localhost", 6379); } + public RedisTimeSeries(String host) { + this(new JedisPool(host)); + } + /** * Create a new RedisTimeSeries client * diff --git a/src/test/java/com/redislabs/redistimeseries/RedisTimeSeriesTest.java b/src/test/java/com/redislabs/redistimeseries/RedisTimeSeriesTest.java index 226b425..963ff61 100644 --- a/src/test/java/com/redislabs/redistimeseries/RedisTimeSeriesTest.java +++ b/src/test/java/com/redislabs/redistimeseries/RedisTimeSeriesTest.java @@ -572,6 +572,20 @@ public void testMRevRange() { new Value[] {new Value(3000L, -33.0), new Value(2000L, 0.0)}, ranges3[1].getValues()); } + @Test + public void testStringHost() { + try (RedisTimeSeries rts = new RedisTimeSeries("localhost")) { + Assert.assertEquals(2100, rts.add("stringConnection", 2100, 2.1)); + } + } + + @Test + public void testStringURI() { + try (RedisTimeSeries rts = new RedisTimeSeries("redis://default:@localhost:6379/0")) { + Assert.assertEquals(2200, rts.add("uriConnection", 2200, 2.2)); + } + } + @Test public void testCloseable() { JedisPool closeablePool = new JedisPool();