List of usage examples for org.springframework.data.redis.connection DefaultStringRedisConnection set
@Override
public Boolean set(String key, String value)
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@SuppressWarnings("rawtypes") @Test// w w w . ja v a 2 s .com public void testGetNewConnectionOnError() throws Exception { factory.setValidateConnection(true); connection.lPush("alist", "baz"); RedisAsyncCommands nativeConn = (RedisAsyncCommands) connection.getNativeConnection(); nativeConn.getStatefulConnection().close(); // Give some time for async channel close Thread.sleep(500); connection.bLPop(1, "alist".getBytes()); try { connection.get("test3"); fail("Expected exception using natively closed conn"); } catch (RedisSystemException e) { // expected, shared conn is closed } DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(factory.getConnection()); assertNotSame(nativeConn, conn2.getNativeConnection()); conn2.set("anotherkey", "anothervalue"); assertEquals("anothervalue", conn2.get("anotherkey")); conn2.close(); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@SuppressWarnings("rawtypes") @Test// ww w . j av a 2s . com public void testConnectionErrorNoValidate() throws Exception { connection.lPush("ablist", "baz"); ((RedisAsyncCommands) connection.getNativeConnection()).getStatefulConnection().close(); // Give some time for async channel close Thread.sleep(500); DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(factory.getConnection()); try { conn2.set("anotherkey", "anothervalue"); fail("Expected exception using natively closed conn"); } catch (RedisSystemException e) { // expected, as we are re-using the natively closed conn } finally { conn2.close(); } }