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


Java RedisCommands.get方法代码示例

本文整理汇总了Java中com.lambdaworks.redis.api.sync.RedisCommands.get方法的典型用法代码示例。如果您正苦于以下问题:Java RedisCommands.get方法的具体用法?Java RedisCommands.get怎么用?Java RedisCommands.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lambdaworks.redis.api.sync.RedisCommands的用法示例。


在下文中一共展示了RedisCommands.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPooling

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test
public void testPooling() throws Exception {
    final RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();

    assertThat(pool.getNumActive()).isEqualTo(0);
    assertThat(pool.getNumIdle()).isEqualTo(0);

    new WithConnection<RedisCommands<String, String>>(pool) {

        @Override
        protected void run(RedisCommands<String, String> connection) {
            connection.set("key", "value");
            String result = connection.get("key");
            assertThat(result).isEqualTo("value");

            assertThat(pool.getNumActive()).isEqualTo(1);
            assertThat(pool.getNumIdle()).isEqualTo(0);
        }
    };

    assertThat(pool.getNumActive()).isEqualTo(0);
    assertThat(pool.getNumIdle()).isEqualTo(1);

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

示例2: pingBeforeConnect

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
@Test(timeout = 10000)
public void pingBeforeConnect() {

    redis.set(key, value);
    client.setOptions(ClientOptions.builder().pingBeforeActivateConnection(true).build());
    RedisCommands<String, String> connection = client.connect().sync();

    try {
        String result = connection.get(key);
        assertThat(result).isEqualTo(value);
    } finally {
        connection.close();
    }
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:ClientOptionsTest.java

示例3: get

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的package包/类
/**
 * Gets a value from Redis.
 * @param key The key.
 * @return The value, can be null.
 */
public String get(String key) {
    RedisCommands resource = redis.getResource();
    Object result = resource.get(UDatabase.getKey(category, key));
    return result == null ? null : result.toString();
}
 
开发者ID:Arraying,项目名称:Arraybot,代码行数:11,代码来源:KVEntry.java

示例4: main

import com.lambdaworks.redis.api.sync.RedisCommands; //导入方法依赖的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();
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:19,代码来源:ReadWriteExample.java


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