Examples of RedisConnection


Examples of org.springframework.data.redis.connection.RedisConnection

      if (log.isDebugEnabled()) {
        log.debug(String.format("Invoke '%s' on unbound conneciton", method.getName()));
      }

      RedisConnection connection = factory.getConnection();

      try {
        return invoke(method, connection, args);
      } finally {
        // properly close the unbound connection after executing command
        if (!connection.isClosed()) {
          connection.close();
        }
      }
    }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

    ConnectionFactoryTracker.add(factory);
  }

  @After
  public void stop() {
    RedisConnection connection = factory.getConnection();
    connection.flushDb();
    connection.close();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

*/
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

Examples of org.springframework.data.redis.connection.RedisConnection

  @Test
  public void testConnect() {
    SrpConnectionFactory factory = new SrpConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
    factory.afterPropertiesSet();
    RedisConnection connection = factory.getConnection();
    connection.ping();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

  @Test
  public void testConnectWithPassword() {
    SrpConnectionFactory factory = new SrpConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
    factory.setPassword("foob");
    factory.afterPropertiesSet();
    RedisConnection connection = factory.getConnection();
    connection.ping();
    RedisConnection connection2 = factory.getConnection();
    connection2.ping();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

  public <T> T execute(RedisCallback<T> action, boolean exposeConnection, boolean pipeline) {
    Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
    Assert.notNull(action, "Callback object must not be null");

    RedisConnectionFactory factory = getConnectionFactory();
    RedisConnection conn = null;
    try {

      if (enableTransactionSupport) {
        // only bind resources in case of potential transaction synchronization
        conn = RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
      } else {
        conn = RedisConnectionUtils.getConnection(factory);
      }

      boolean existingConnection = TransactionSynchronizationManager.hasResource(factory);

      RedisConnection connToUse = preProcessConnection(conn, existingConnection);

      boolean pipelineStatus = connToUse.isPipelined();
      if (pipeline && !pipelineStatus) {
        connToUse.openPipeline();
      }

      RedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse));
      T result = action.doInRedis(connToExpose);

      // close pipeline
      if (pipeline && !pipelineStatus) {
        connToUse.closePipeline();
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

      container.stop();
      containers.add(container);
    }

    // verify we can now get a connection from the pool
    RedisConnection connection = connectionFactory.getConnection();
    connection.close();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

    // Removing the sole listener from the container should free up a
    // connection
    containers.get(0).removeMessageListener(listener);

    // verify we can now get a connection from the pool
    RedisConnection connection = connectionFactory.getConnection();
    connection.close();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

    // Unsubscribe all listeners from all topics, freeing up a connection
    containers.get(0).removeMessageListener(null, Arrays.asList(new Topic[] {}));

    // verify we can now get a connection from the pool
    RedisConnection connection = connectionFactory.getConnection();
    connection.close();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

  @Test
  public void testConnectionStaysOpenWhenPooled() {
    JredisConnectionFactory factory2 = new JredisConnectionFactory(new JredisPool(SettingsUtils.getHost(),
        SettingsUtils.getPort()));
    RedisConnection conn2 = factory2.getConnection();
    conn2.close();
    conn2.ping();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.