本文整理汇总了Java中com.lambdaworks.redis.api.StatefulRedisConnection.close方法的典型用法代码示例。如果您正苦于以下问题:Java StatefulRedisConnection.close方法的具体用法?Java StatefulRedisConnection.close怎么用?Java StatefulRedisConnection.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lambdaworks.redis.api.StatefulRedisConnection
的用法示例。
在下文中一共展示了StatefulRedisConnection.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertionRemoval
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void insertionRemoval() throws NumberFormatException, InterruptedException, ExecutionException {
RedisClient redis = RedisClient.create("redis://127.0.0.1:6379");
StatefulRedisConnection<String, String> redisConn = redis.connect();
RedisAsyncCommands<String, String> redisCmd = redisConn.async();
long iterations = 1000;
for (long i = 0; i < iterations; i++) {
redisCmd.set(String.valueOf(i), String.valueOf(i + 1));
}
for (long i = 0; i < iterations; i++) {
long v = Long.valueOf(redisCmd.get(String.valueOf(i)).get());
assertEquals(i + 1, v);
}
for (long i = 0; i < iterations; i++) {
redisCmd.del(String.valueOf(i));
}
redisConn.close();
redis.shutdown();
}
示例2: main
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
public static void main(String[] args) {
// Syntax: redis://[[email protected]]host[:port][/databaseNumber]
RedisClient redisClient = RedisClient.create("redis://[email protected]:6379/0");
StatefulRedisConnection<String, String> connection = redisClient.connect();
System.out.println("Connected to Redis");
connection.close();
redisClient.shutdown();
}
示例3: connectCodecOwnUri
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void connectCodecOwnUri() throws Exception {
RedisURI redisURI = redis(host, port).build();
StatefulRedisConnection<String, String> connection = client.connect(CODEC, redisURI);
assertTimeout(connection, redisURI.getTimeout(), redisURI.getUnit());
connection.close();
}
示例4: requestQueueSizeOvercommittedReconnect
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void requestQueueSizeOvercommittedReconnect() throws Exception {
client.setOptions(ClientOptions.builder().requestQueueSize(10).build());
StatefulRedisConnection<String, String> connection = client.connect();
ConnectionWatchdog watchdog = getConnectionWatchdog(connection);
watchdog.setListenOnChannelInactive(false);
Queue<Object> buffer = getStack(connection);
List<RedisFuture<String>> pings = new ArrayList<>();
for (int i = 0; i < 11; i++) {
AsyncCommand<String, String, String> command = new AsyncCommand<>(new Command<>(CommandType.PING,
new StatusOutput<>(StringCodec.UTF8)));
pings.add(command);
buffer.add(command);
}
getChannel(connection).disconnect();
Wait.untilTrue(() -> !connection.isOpen()).waitOrTimeout();
watchdog.setListenOnChannelInactive(true);
watchdog.scheduleReconnect();
for (int i = 0; i < 10; i++) {
assertThat(pings.get(i).get()).isEqualTo("PONG");
}
assertThatThrownBy(() -> pings.get(10).toCompletableFuture().join()).hasCauseInstanceOf(IllegalStateException.class)
.hasMessage("java.lang.IllegalStateException: Queue full");
connection.close();
}
示例5: testJavaSerializer
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void testJavaSerializer() throws Exception {
StatefulRedisConnection<String, Object> redisConnection = client.connect(new SerializedObjectCodec());
RedisCommands<String, Object> sync = redisConnection.sync();
List<String> list = list("one", "two");
sync.set(key, list);
assertThat(sync.get(key)).isEqualTo(list);
assertThat(sync.set(key, list)).isEqualTo("OK");
assertThat(sync.set(key, list, SetArgs.Builder.ex(1))).isEqualTo("OK");
redisConnection.close();
}
示例6: testJavaSerializerRx
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void testJavaSerializerRx() throws Exception {
StatefulRedisConnection<String, Object> redisConnection = client.connect(new SerializedObjectCodec());
List<String> list = list("one", "two");
TestSubscriber<String> subscriber = TestSubscriber.create();
redisConnection.reactive().set(key, list, SetArgs.Builder.ex(1)).subscribe(subscriber);
subscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
subscriber.assertCompleted();
subscriber.assertValue("OK");
redisConnection.close();
}
示例7: connectClientUri
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void connectClientUri() throws Exception {
StatefulRedisConnection<String, String> connection = client.connect();
assertTimeout(connection, EXPECTED_TIMEOUT, EXPECTED_TIME_UNIT);
connection.close();
}
示例8: sentinel_ConnectToSocket
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void sentinel_ConnectToSocket() throws Exception {
assumeTestSupported();
RedisURI uri = new RedisURI();
uri.getSentinels().add(getSentinelSocketRedisUri());
uri.setSentinelMasterId("mymaster");
RedisClient redisClient = RedisClient.create(TestClientResources.get());
StatefulRedisConnection<String, String> connection = redisClient.connect(uri);
someRedisAction(connection.sync());
connection.close();
RedisSentinelAsyncConnection<String, String> sentinelConnection = redisClient.connectSentinelAsync(uri);
assertThat(sentinelConnection.ping().get()).isEqualTo("PONG");
sentinelConnection.close();
FastShutdown.shutdown(redisClient);
}
示例9: close
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
/**
* Close all connections.
*/
public void close() {
for (StatefulRedisConnection<String, String> connection : connections.values()) {
connection.close();
}
}
示例10: main
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
public static void main(String[] args) {
// Syntax: redis://[[email protected]]host[:port][/databaseNumber]
DefaultClientResources clientResources = DefaultClientResources.builder() //
.dnsResolver(new DirContextDnsResolver()) // Does not cache DNS lookups
.build();
RedisClient redisClient = RedisClient.create(clientResources, "redis://[email protected]:6379/0");
StatefulRedisConnection<String, String> connection = redisClient.connect();
System.out.println("Connected to Redis");
connection.close();
redisClient.shutdown();
}
示例11: main
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"com/lambdaworks/examples/SpringTest-context.xml");
RedisClient client = context.getBean(RedisClient.class);
StatefulRedisConnection<String, String> connection = client.connect();
RedisCommands<String, String> sync = connection.sync();
System.out.println("PING: " + sync.ping());
connection.close();
MySpringBean mySpringBean = context.getBean(MySpringBean.class);
System.out.println("PING: " + mySpringBean.ping());
context.close();
}
示例12: connectCodecClientUri
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void connectCodecClientUri() throws Exception {
StatefulRedisConnection<String, String> connection = client.connect(CODEC);
assertTimeout(connection, EXPECTED_TIMEOUT, EXPECTED_TIME_UNIT);
connection.close();
}
示例13: sentinel_RedisClientWithSocket
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void sentinel_RedisClientWithSocket() throws Exception {
assumeTestSupported();
RedisURI uri = new RedisURI();
uri.getSentinels().add(getSentinelSocketRedisUri());
uri.setSentinelMasterId("mymaster");
RedisClient redisClient = RedisClient.create(TestClientResources.get(), uri);
StatefulRedisConnection<String, String> connection = redisClient.connect();
someRedisAction(connection.sync());
connection.close();
RedisSentinelAsyncConnection<String, String> sentinelConnection = redisClient.connectSentinelAsync();
assertThat(sentinelConnection.ping().get()).isEqualTo("PONG");
sentinelConnection.close();
FastShutdown.shutdown(redisClient);
}
示例14: main
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
public static void main(String[] args) {
// Syntax: redis://[[email protected]]host[:port][/databaseNumber]
RedisClient redisClient = RedisClient.create(RedisURI.create("redis://[email protected]:6379/0"));
StatefulRedisConnection<String, String> connection = redisClient.connect();
System.out.println("Connected to Redis");
RedisCommands<String, String> sync = connection.sync();
sync.set("foo", "bar");
String value = sync.get("foo");
System.out.println(value);
connection.close();
redisClient.shutdown();
}
示例15: standaloneConnectionShouldSetClientName
import com.lambdaworks.redis.api.StatefulRedisConnection; //导入方法依赖的package包/类
@Test
public void standaloneConnectionShouldSetClientName() throws Exception {
RedisURI redisURI = RedisURI.create(host, port);
redisURI.setClientName("my-client");
StatefulRedisConnection<String, String> connection = client.connect(redisURI);
assertThat(connection.sync().clientGetname()).isEqualTo(redisURI.getClientName());
connection.sync().quit();
Thread.sleep(100);
assertThat(connection.sync().clientGetname()).isEqualTo(redisURI.getClientName());
connection.close();
}