当前位置: 首页>>代码示例>>Java>>正文


Java RedisCommands.ping方法代码示例

本文整理汇总了Java中com.lambdaworks.redis.api.sync.RedisCommands.ping方法的典型用法代码示例。如果您正苦于以下问题:Java RedisCommands.ping方法的具体用法?Java RedisCommands.ping怎么用?Java RedisCommands.ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lambdaworks.redis.api.sync.RedisCommands的用法示例。


在下文中一共展示了RedisCommands.ping方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrappedObjectClosedAfterReturn

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void wrappedObjectClosedAfterReturn() throws Exception {

    GenericObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport.createGenericObjectPool(
            () -> client.connect(), new GenericObjectPoolConfig(), true);

    StatefulRedisConnection<String, String> connection = pool.borrowObject();
    RedisCommands<String, String> sync = connection.sync();
    sync.ping();
    sync.close();

    try {
        connection.isMulti();
        fail("Missing RedisException");
    } catch (RedisException e) {
        assertThat(e).hasMessageContaining("deallocated");
    }

    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:21,代码来源:ConnectionPoolSupportTest.java

示例2: tryWithResourcesReturnsConnectionToPool

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void tryWithResourcesReturnsConnectionToPool() throws Exception {

    GenericObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport.createGenericObjectPool(
            () -> client.connect(), new GenericObjectPoolConfig());

    StatefulRedisConnection<String, String> usedConnection = null;
    try (StatefulRedisConnection<String, String> connection = pool.borrowObject()) {

        RedisCommands<String, String> sync = connection.sync();
        sync.ping();

        usedConnection = connection;
    }

    try {
        usedConnection.isMulti();
        fail("Missing RedisException");
    } catch (RedisException e) {
        assertThat(e).hasMessageContaining("deallocated");
    }

    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:25,代码来源:ConnectionPoolSupportTest.java

示例3: tryWithResourcesReturnsSoftRefConnectionToPool

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void tryWithResourcesReturnsSoftRefConnectionToPool() throws Exception {

    SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport
            .createSoftReferenceObjectPool(() -> client.connect());

    StatefulRedisConnection<String, String> usedConnection = null;
    try (StatefulRedisConnection<String, String> connection = pool.borrowObject()) {

        RedisCommands<String, String> sync = connection.sync();
        sync.ping();

        usedConnection = connection;
    }

    try {
        usedConnection.isMulti();
        fail("Missing RedisException");
    } catch (RedisException e) {
        assertThat(e).hasMessageContaining("deallocated");
    }

    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:25,代码来源:ConnectionPoolSupportTest.java

示例4: twoConnections

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void twoConnections() throws Exception {

    RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
    RedisCommands<String, String> c1 = pool.allocateConnection();
    RedisConnection<String, String> c2 = pool.allocateConnection();

    String result1 = c1.ping();
    String result2 = c2.ping();
    assertThat(result1).isEqualTo("PONG");
    assertThat(result2).isEqualTo("PONG");

    c1.close();
    c2.close();
    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:17,代码来源:PoolConnectionTest.java

示例5: ping

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
public String ping() {

        StatefulRedisConnection<String, String> connection = redisClient.connect();

        RedisCommands<String, String> sync = connection.sync();
        String result = sync.ping();
        connection.close();
        return result;
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:10,代码来源:MySpringBean.java

示例6: borrowAndReturn

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
private void borrowAndReturn(ObjectPool<StatefulRedisConnection<String, String>> pool) throws Exception {

        for (int i = 0; i < 10; i++) {
            StatefulRedisConnection<String, String> connection = pool.borrowObject();
            RedisCommands<String, String> sync = connection.sync();
            sync.ping();
            pool.returnObject(connection);
        }
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:10,代码来源:ConnectionPoolSupportTest.java

示例7: borrowAndCloseTryWithResources

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
private void borrowAndCloseTryWithResources(ObjectPool<StatefulRedisConnection<String, String>> pool) throws Exception {

        for (int i = 0; i < 10; i++) {
            try (StatefulRedisConnection<String, String> connection = pool.borrowObject()) {
                RedisCommands<String, String> sync = connection.sync();
                sync.ping();
            }
        }
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:10,代码来源:ConnectionPoolSupportTest.java

示例8: borrowAndClose

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
private void borrowAndClose(ObjectPool<StatefulRedisConnection<String, String>> pool) throws Exception {

        for (int i = 0; i < 10; i++) {
            StatefulRedisConnection<String, String> connection = pool.borrowObject();
            RedisCommands<String, String> sync = connection.sync();
            sync.ping();
            sync.close();
        }
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:10,代码来源:ConnectionPoolSupportTest.java

示例9: connectionsClosedAfterPoolClose

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void connectionsClosedAfterPoolClose() throws Exception {

    RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
    RedisCommands<String, String> c1 = pool.allocateConnection();
    pool.freeConnection(c1);
    pool.close();

    try {
        c1.ping();
        fail("Missing Exception: Connection closed");
    } catch (Exception e) {
    }
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:PoolConnectionTest.java

示例10: connectionNotClosedWhenBorrowed2

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void connectionNotClosedWhenBorrowed2() throws Exception {

    RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
    RedisCommands<String, String> c1 = pool.allocateConnection();
    pool.freeConnection(c1);
    c1 = pool.allocateConnection();
    pool.close();

    c1.ping();
    c1.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:13,代码来源:PoolConnectionTest.java

示例11: softRefPoolShouldWorkWithWrappedConnections

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void softRefPoolShouldWorkWithWrappedConnections() throws Exception {

    SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport
            .createSoftReferenceObjectPool(() -> client.connect());

    StatefulRedisConnection<String, String> connection = pool.borrowObject();

    assertThat(channels).hasSize(1);

    RedisCommands<String, String> sync = connection.sync();
    sync.ping();
    sync.close();

    pool.close();

    Wait.untilTrue(channels::isEmpty).waitOrTimeout();

    assertThat(channels).isEmpty();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:21,代码来源:ConnectionPoolSupportTest.java


注:本文中的com.lambdaworks.redis.api.sync.RedisCommands.ping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。