Package org.springframework.data.redis.connection

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


    if (isActualNonReadonlyTransactionActive()) {

      if (!connHolder.isTransactionSyncronisationActive()) {
        connHolder.setTransactionSyncronisationActive(true);
       
        RedisConnection conn = connHolder.getConnection();
        conn.multi();

        TransactionSynchronizationManager.registerSynchronization(new RedisTransactionSynchronizer(connHolder, conn));
      }
    }
  }
View Full Code Here


        }
      } else {
        if (log.isDebugEnabled()) {
          log.debug("Closing bound connection.");
        }
        RedisConnection connection = connHolder.getConnection();
        connection.close();
      }
    }

  }
View Full Code Here

      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

    ConnectionFactoryTracker.add(factory);
  }

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

*/
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 testConnect() {
    SrpConnectionFactory factory = new SrpConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
    factory.afterPropertiesSet();
    RedisConnection connection = factory.getConnection();
    connection.ping();
  }
View Full Code Here

  @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

  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

      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

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

TOP

Related Classes of org.springframework.data.redis.connection.RedisConnection

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.