本文整理汇总了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);
}
示例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();
}
}
示例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();
}
示例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();
}