List of usage examples for org.springframework.data.redis.connection DefaultStringRedisConnection DefaultStringRedisConnection
public DefaultStringRedisConnection(RedisConnection connection)
DefaultStringRedisConnection
instance. From source file:com.mauersu.util.redis.MyStringRedisTemplate.java
protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) { return new DefaultStringRedisConnection(connection); }
From source file:com.hstech.monkey.redis.ObjectRedisTemplate.java
@Override protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) { return new DefaultStringRedisConnection(connection); }
From source file:com.ge.predix.acs.policy.evaluation.cache.RedisPolicyEvaluationCache.java
@Override List<Object> multiGetResourceTranslations(final List<String> fromKeys) { // Pipelining makes sure we don't pay excessive RTT penalties. return this.redisTemplate.executePipelined(new RedisCallback<List<Object>>() { @Override/* ww w . ja v a2 s. c om*/ public List<Object> doInRedis(final RedisConnection connection) throws DataAccessException { StringRedisConnection stringRedisConn = new DefaultStringRedisConnection(connection); for (String fromKey : fromKeys) { stringRedisConn.sMembers(fromKey); } return null; } }, new StringRedisSerializer()); }
From source file:com.ge.predix.acs.policy.evaluation.cache.RedisPolicyEvaluationCache.java
@Override void setResourceTranslations(final Set<String> fromKeys, final String toKey) { this.redisTemplate.execute(new RedisCallback<List<Object>>() { @Override/*from ww w. java2s.c o m*/ public List<Object> doInRedis(final RedisConnection connection) throws DataAccessException { StringRedisConnection stringRedisConn = new DefaultStringRedisConnection(connection); for (String fromKey : fromKeys) { stringRedisConn.sAdd(fromKey, toKey); } return null; } }); }
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);//www . j a va 2s.c om 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
@Before public void setUp() { factory = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort()); factory.setClientResources(LettuceTestClientResources.getSharedClientResources()); factory.afterPropertiesSet();// w w w .j a v a 2 s.c om factory.setShutdownTimeout(0); connection = new DefaultStringRedisConnection(factory.getConnection()); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@SuppressWarnings("rawtypes") @Test/*from w w w.j a v a 2s .c om*/ 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//from w ww . j a v a 2s . c o m 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(); } }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test public void testSelectDb() { LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());/*from w ww .j a v a2 s . co 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);//w w w . j a v a2 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(); } }