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


Java RedisConnection.set方法代码示例

本文整理汇总了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");

    }
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:17,代码来源:PoolingProxyFactoryTest.java

示例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();
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:37,代码来源:TestRestService.java

示例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";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:31,代码来源:RedisService.java

示例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();
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:16,代码来源:DoTestLettuceHookProxy.java

示例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());

}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:14,代码来源:TransactionCommandTest.java

示例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();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:12,代码来源:PoolingProxyFactoryTest.java


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