本文整理了Java中redis.clients.jedis.Jedis.get()
方法的一些代码示例,展示了Jedis.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.get()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:get
[英]Get the value of the specified key. If the key does not exist null is returned. If the value stored at key is not a string an error is returned because GET can only handle string values.
Time complexity: O(1)
[中]获取指定键的值。如果密钥不存在,则返回null。如果键处存储的值不是字符串,则返回错误,因为GET只能处理字符串值。
时间复杂度:O(1)
代码示例来源:origin: sohutv/cachecloud
@Override
public byte[] execute(Jedis connection) {
return connection.get(key);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.get(key);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public byte[] execute(Jedis connection) {
return connection.get(keyByte);
}
}.runBinary(keyByte);
代码示例来源:origin: yu199195/hmily
@Override
public byte[] get(final byte[] key) {
try (Jedis jedis = jedisPool.getResource()) {
return jedis.get(key);
}
}
代码示例来源:origin: yu199195/hmily
@Override
public String get(final String key) {
try (Jedis jedis = jedisPool.getResource()) {
return jedis.get(key);
}
}
代码示例来源:origin: sohutv/cachecloud
@Override
public byte[] get(byte[] key) {
Jedis j = getShard(key);
return j.get(key);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String get(String key) {
Jedis j = getShard(key);
return j.get(key);
}
代码示例来源:origin: looly/hutool
/**
* 从Redis中获取值
*
* @param key 键
* @return 值
*/
public String getStr(String key) {
try (Jedis jedis = getJedis()) {
return jedis.get(key);
}
}
代码示例来源:origin: looly/hutool
/**
* 从Redis中获取值
*
* @param key 键
* @return 值
*/
public String getStr(String key) {
try (Jedis jedis = getJedis()) {
return jedis.get(key);
}
}
代码示例来源:origin: yu199195/hmily
@Override
public byte[] get(final byte[] key) {
try (Jedis jedis = jedisSentinelPool.getResource()) {
return jedis.get(key);
}
}
代码示例来源:origin: yu199195/hmily
@Override
public String get(final String key) {
try (Jedis jedis = jedisSentinelPool.getResource()) {
return jedis.get(key);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 获取String值
* @param key
* @return value
*/
public synchronized static String get(String key) {
Jedis jedis = getJedis();
if (null == jedis) {
return null;
}
String value = jedis.get(key);
jedis.close();
return value;
}
代码示例来源:origin: shuzheng/zheng
/**
* 获取byte[]值
* @param key
* @return value
*/
public synchronized static byte[] get(byte[] key) {
Jedis jedis = getJedis();
if (null == jedis) {
return null;
}
byte[] value = jedis.get(key);
jedis.close();
return value;
}
代码示例来源:origin: qiurunze123/miaosha
public String get(String key){
Jedis jedis = null;
String result = null;
try {
jedis = jedisPool.getResource();
result = jedis.get(key);
} catch (Exception e) {
log.error("expire key:{} error",key,e);
jedisPool.returnBrokenResource(jedis);
return result;
}
jedisPool.returnResource(jedis);
return result;
}
代码示例来源:origin: jfinal/jfinal
/**
* 获取记数器的值
*/
public Long getCounter(Object key) {
Jedis jedis = getJedis();
try {
String ret = (String)jedis.get(keyNamingPolicy.getKeyName(key));
return ret != null ? Long.parseLong(ret) : null;
}
finally {close(jedis);}
}
代码示例来源:origin: jfinal/jfinal
/**
* 返回 key 所关联的 value 值
* 如果 key 不存在那么返回特殊值 nil 。
*/
@SuppressWarnings("unchecked")
public <T> T get(Object key) {
Jedis jedis = getJedis();
try {
return (T)valueFromBytes(jedis.get(keyToBytes(key)));
}
finally {close(jedis);}
}
代码示例来源:origin: testcontainers/testcontainers-java
@Test
public void simpleTest() {
for (int i = 0; i < 3; i++) {
clients[i].incr("somekey");
assertEquals("Each redis instance is separate", "1", clients[i].get("somekey"));
}
}
}
代码示例来源:origin: apache/ignite
private void testExpire(Expiration exp) throws Exception {
try (Jedis jedis = pool.getResource()) {
jedis.set("k1", "v1");
Assert.assertTrue(jedis.exists("k1"));
Assert.assertEquals(1L, exp.expire(jedis, "k1"));
Assert.assertEquals("v1", jedis.get("k1"));
Thread.sleep(2100);
Assert.assertFalse(jedis.exists("k1"));
Assert.assertEquals(0L, (long)jedis.expire("k1", 2));
}
}
代码示例来源:origin: testcontainers/testcontainers-java
@Test
public void simpleTest() {
Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));
jedis.incr("test");
jedis.incr("test");
jedis.incr("test");
assertEquals("A redis instance defined in compose can be used in isolation", "3", jedis.get("test"));
}
代码示例来源:origin: testcontainers/testcontainers-java
@Test
public void secondTest() {
// used in manual checking for cleanup in between tests
Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));
jedis.incr("test");
jedis.incr("test");
jedis.incr("test");
assertEquals("Tests use fresh container instances", "3", jedis.get("test"));
// if these end up using the same container one of the test methods will fail.
// However, @Rule creates a separate DockerComposeContainer instance per test, so this just shouldn't happen
}
内容来源于网络,如有侵权,请联系作者删除!