本文整理汇总了Java中com.lambdaworks.redis.RedisConnection.close方法的典型用法代码示例。如果您正苦于以下问题:Java RedisConnection.close方法的具体用法?Java RedisConnection.close怎么用?Java RedisConnection.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lambdaworks.redis.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clientKillExtended
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@Test
public void clientKillExtended() {
RedisConnection<String, String> connection2 = client.connect().sync();
connection2.clientSetname("killme");
Pattern p = Pattern.compile("^.*addr=([^ ]+).*name=killme.*$", Pattern.MULTILINE | Pattern.DOTALL);
String clients = redis.clientList();
Matcher m = p.matcher(clients);
assertThat(m.matches()).isTrue();
String addr = m.group(1);
assertThat(redis.clientKill(KillArgs.Builder.addr(addr).skipme())).isGreaterThan(0);
assertThat(redis.clientKill(KillArgs.Builder.id(4234))).isEqualTo(0);
assertThat(redis.clientKill(KillArgs.Builder.typeSlave().id(4234))).isEqualTo(0);
assertThat(redis.clientKill(KillArgs.Builder.typeNormal().id(4234))).isEqualTo(0);
assertThat(redis.clientKill(KillArgs.Builder.typePubsub().id(4234))).isEqualTo(0);
connection2.close();
}
示例2: testCreate
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@Test
public void testCreate() throws Exception {
RedisConnection<String, String> connection = PoolingProxyFactory.create(client.pool());
connection.set("a", "b");
connection.close();
try {
connection.set("x", "y");
fail("missing exception");
} catch (RedisException e) {
assertThat(e.getMessage()).isEqualTo("Connection pool is closed");
}
}
示例3: testLettuce
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@POST
@Path("testLettuce")
public void testLettuce(String jsonString) {
RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
RedisConnection<String, String> conn1 = redisClient.connect();
conn1.set("foo", "bar");
String value = conn1.get("foo");
System.out.println(value);
conn1.close();
redisClient.shutdown();
RedisClient client = RedisClient.create("redis://localhost:6379/0");
RedisAsyncConnection<String, String> conn = client.connectAsync();
conn.set("foo", "bar");
conn.get("foo");
conn.lpush("lll", "a");
conn.lpush("lll", "b");
conn.lpush("lll", "c");
conn.lpop("lll");
conn.lpop("lll");
conn.lpop("lll");
conn.hset("mmm", "abc", "123");
conn.hset("mmm", "def", "456");
conn.hgetall("mmm");
conn.del("foo", "lll", "mmm");
conn.close();
client.shutdown();
}
示例4: lettucetest
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@GET
@Path("lettucetest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String lettucetest() {
System.out.println("TEST Lettuce sync ======================================================");
RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
RedisConnection<String, String> conn = redisClient.connect();
conn.set("foo", "bar");
conn.get("foo");
conn.lpush("lll", "a");
conn.lpush("lll", "b");
conn.lpush("lll", "c");
conn.lpop("lll");
conn.lpop("lll");
conn.lpop("lll");
conn.hset("mmm", "abc", "123");
conn.hset("mmm", "def", "456");
conn.hgetall("mmm");
conn.del("foo", "lll", "mmm");
conn.close();
redisClient.shutdown();
return "lettucetest";
}
示例5: testSync
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
private static void testSync() {
System.out.println("TEST Lettuce sync ======================================================");
RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
RedisConnection<String, String> conn = redisClient.connect();
System.out.println("Connected to Redis");
conn.set("foo", "bar");
String value = conn.get("foo");
System.out.println(value);
conn.close();
redisClient.shutdown();
}
示例6: watch
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@Test
public void watch() {
assertThat(redis.watch(key)).isEqualTo("OK");
RedisConnection<String, String> redis2 = client.connect().sync();
redis2.set(key, value + "X");
redis2.close();
redis.multi();
redis.append(key, "foo");
assertThat(redis.exec()).isEqualTo(list());
}
示例7: testCloseReturnsConnection
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@Test
public void testCloseReturnsConnection() throws Exception {
RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
assertThat(pool.getNumActive()).isEqualTo(0);
RedisConnection<String, String> connection = pool.allocateConnection();
assertThat(pool.getNumActive()).isEqualTo(1);
connection.close();
assertThat(pool.getNumActive()).isEqualTo(0);
}