Package org.springframework.data.redis.connection

Examples of org.springframework.data.redis.connection.DefaultStringRedisConnection$StringTupleConverter


    setConnectionFactory(connectionFactory);
    afterPropertiesSet();
  }

  protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) {
    return new DefaultStringRedisConnection(connection);
  }
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

  @Before
  public void setUp() {
    factory = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
    factory.afterPropertiesSet();
    connection = new DefaultStringRedisConnection(factory.getConnection());
  }
View Full Code Here

      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();
  }
View Full Code Here

  public void testConnectionErrorNoValidate() throws Exception {
    connection.lPush("ablist", "baz");
    ((RedisAsyncConnection) connection.getNativeConnection()).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();
    }
  }
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

  @Test
  @IfProfileValue(name = "runLongTests", value = "true")
  public void testMultiThreadsOneBlocking() throws Exception {
    Thread th = new Thread(new Runnable() {
      public void run() {
        DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(connectionFactory.getConnection());
        conn2.openPipeline();
        conn2.bLPop(3, "multilist");
        conn2.closePipeline();
        conn2.close();
      }
    });
    th.start();
    Thread.sleep(1000);
    connection.set("heythere", "hi");
View Full Code Here

  @Test
  public void testMultiConnectionsOneInTx() throws Exception {
    connection.set("txs1", "rightnow");
    connection.multi();
    connection.set("txs1", "delay");
    DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(connectionFactory.getConnection());

    // We get immediate results executing command in separate conn (not part
    // of tx)
    conn2.set("txs2", "hi");
    assertEquals("hi", conn2.get("txs2"));

    // Transactional value not yet set
    assertEquals("rightnow", conn2.get("txs1"));
    connection.exec();

    // Now it should be set
    assertEquals("delay", conn2.get("txs1"));
    conn2.closePipeline();
    conn2.close();
  }
View Full Code Here

      public void run() {
        // Use a different factory to get a non-shared native conn for blocking script
        final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(),
            SettingsUtils.getPort());
        factory2.afterPropertiesSet();
        DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
        try {
          conn2.eval("local time=1 while time < 10000000000 do time=time+1 end", ReturnType.BOOLEAN, 0);
        } catch (DataAccessException e) {
          scriptDead.set(true);
        }
        conn2.close();
        factory2.destroy();
      }
    });
    th.start();
    Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.connection.DefaultStringRedisConnection$StringTupleConverter

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.