本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
}
示例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();
}
}
}
示例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();
}
}
示例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) {
}
}
示例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();
}
示例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();
}