Package org.springframework.data.redis.connection

Examples of org.springframework.data.redis.connection.StringRedisConnection$StringTuple


public class SessionTest {

  @Test
  public void testSession() throws Exception {
    final RedisConnection conn = mock(RedisConnection.class);
    final StringRedisConnection stringConn = mock(StringRedisConnection.class);
    RedisConnectionFactory factory = mock(RedisConnectionFactory.class);
    final StringRedisTemplate template = spy(new StringRedisTemplate(factory));
    when(factory.getConnection()).thenReturn(conn);
    doReturn(stringConn).when(template).preProcessConnection(eq(conn), anyBoolean());
View Full Code Here


  @Test
  public void testStringTemplateExecutesWithStringConn() {
    assumeTrue(redisTemplate instanceof StringRedisTemplate);
    String value = redisTemplate.execute(new RedisCallback<String>() {
      public String doInRedis(RedisConnection connection) {
        StringRedisConnection stringConn = (StringRedisConnection) connection;
        stringConn.set("test", "it");
        return stringConn.get("test");
      }
    });
    assertEquals(value, "it");
  }
View Full Code Here

  @Test
  public void testExecutePipelinedCustomSerializer() {
    assumeTrue(redisTemplate instanceof StringRedisTemplate);
    List<Object> results = redisTemplate.executePipelined(new RedisCallback() {
      public Object doInRedis(RedisConnection connection) throws DataAccessException {
        StringRedisConnection stringRedisConn = (StringRedisConnection) connection;
        stringRedisConn.set("foo", "5");
        stringRedisConn.get("foo");
        stringRedisConn.rPush("foolist", "10");
        stringRedisConn.rPush("foolist", "11");
        stringRedisConn.lRange("foolist", 0, -1);
        return null;
      }
    }, new GenericToStringSerializer<Long>(Long.class));
    assertEquals(Arrays.asList(new Object[] { 5l, 1l, 2l, Arrays.asList(new Long[] { 10l, 11l }) }), results);
  }
View Full Code Here

    verifyResults(Arrays.asList(new Object[] { true }));
    // JRedis does not support select() on existing conn, create new one
    JredisConnectionFactory factory2 = new JredisConnectionFactory();
    factory2.setDatabase(1);
    factory2.afterPropertiesSet();
    StringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
    try {
      assertEquals("bar", conn2.get("foo"));
    } finally {
      if (conn2.exists("foo")) {
        conn2.del("foo");
      }
      conn2.close();
    }
  }
View Full Code Here

    verifyResults(Arrays.asList(new Object[] { true }));
    // Lettuce does not support select when using shared conn, use a new conn factory
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory();
    factory2.setDatabase(1);
    factory2.afterPropertiesSet();
    StringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
    try {
      assertEquals("bar", conn2.get("foo"));
    } finally {
      if (conn2.exists("foo")) {
        conn2.del("foo");
      }
      conn2.close();
      factory2.destroy();
    }
  }
View Full Code Here

  @Test
  public void testSelectDb() {
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
    factory2.setDatabase(1);
    factory2.afterPropertiesSet();
    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();
    }
  }
View Full Code Here

    verifyResults(Arrays.asList(new Object[] { true }));
    // Lettuce does not support select when using shared conn, use a new conn factory
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory();
    factory2.setDatabase(1);
    factory2.afterPropertiesSet();
    StringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
    try {
      assertEquals("bar", conn2.get("foo"));
    } finally {
      if (conn2.exists("foo")) {
        conn2.del("foo");
      }
      conn2.close();
      factory2.destroy();
    }
  }
View Full Code Here

    verifyResults(Arrays.asList(new Object[] { true }));
    // Lettuce does not support select when using shared conn, use a new conn factory
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory();
    factory2.setDatabase(1);
    factory2.afterPropertiesSet();
    StringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
    try {
      assertEquals("bar", conn2.get("foo"));
    } finally {
      if (conn2.exists("foo")) {
        conn2.del("foo");
      }
      conn2.close();
      factory2.destroy();
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.connection.StringRedisConnection$StringTuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.