本文整理汇总了Java中com.lambdaworks.redis.RedisConnection.set方法的典型用法代码示例。如果您正苦于以下问题:Java RedisConnection.set方法的具体用法?Java RedisConnection.set怎么用?Java RedisConnection.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lambdaworks.redis.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
示例2: 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();
}
示例3: 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";
}
示例4: 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();
}
示例5: 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());
}
示例6: testCreateDefault
import com.lambdaworks.redis.RedisConnection; //导入方法依赖的package包/类
@Test
public void testCreateDefault() throws Exception {
RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
RedisConnection<String, String> connection = PoolingProxyFactory.create(pool);
connection.set("a", "b");
connection.set("x", "y");
pool.close();
}