List of usage examples for org.springframework.data.redis.connection StringRedisConnection close
void close() throws DataAccessException;
From source file:org.springframework.data.redis.connection.jredis.JRedisConnectionIntegrationTests.java
@Test public void testMove() { connection.set("foo", "bar"); actual.add(connection.move("foo", 1)); verifyResults(Arrays.asList(new Object[] { true })); // JRedis does not support select() on existing conn, create new one JredisConnectionFactory factory2 = new JredisConnectionFactory(); factory2.setDatabase(1);//from w w w . jav a 2 s. c o m factory2.afterPropertiesSet(); StringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection()); try { assertEquals("bar", conn2.get("foo")); } finally { if (conn2.exists("foo")) { conn2.del("foo"); } conn2.close(); } }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test public void testSelectDb() { LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());// w w w . j a v a 2 s . c o m factory2.setClientResources(LettuceTestClientResources.getSharedClientResources()); factory2.setShutdownTimeout(0); factory2.setDatabase(1); factory2.afterPropertiesSet(); ConnectionFactoryTracker.add(factory2); StringRedisConnection connection2 = new DefaultStringRedisConnection(factory2.getConnection()); connection2.flushDb(); // put an item in database 0 connection.set("sometestkey", "sometestvalue"); try { // there should still be nothing in database 1 assertEquals(Long.valueOf(0), connection2.dbSize()); } finally { connection2.close(); factory2.destroy(); } }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-431 public void dbIndexShouldBePropagatedCorrectly() { LettuceConnectionFactory factory = new LettuceConnectionFactory(); factory.setClientResources(LettuceTestClientResources.getSharedClientResources()); factory.setDatabase(2);/*from w ww.j av a 2 s .c o m*/ factory.afterPropertiesSet(); ConnectionFactoryTracker.add(factory); StringRedisConnection connectionToDbIndex2 = new DefaultStringRedisConnection(factory.getConnection()); try { String key = "key-in-db-2"; connectionToDbIndex2.set(key, "the wheel of time"); assertThat(connection.get(key), nullValue()); assertThat(connectionToDbIndex2.get(key), notNullValue()); } finally { connectionToDbIndex2.close(); } }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-462 public void factoryWorksWithoutClientResources() { LettuceConnectionFactory factory = new LettuceConnectionFactory(); factory.setShutdownTimeout(0);//from w w w .ja v a 2s. c om factory.afterPropertiesSet(); ConnectionFactoryTracker.add(factory); StringRedisConnection connection = new DefaultStringRedisConnection(factory.getConnection()); try { assertThat(connection.ping(), is(equalTo("PONG"))); } finally { connection.close(); } }