本文整理了Java中redis.clients.jedis.Jedis.set()
方法的一些代码示例,展示了Jedis.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.set()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:set
[英]Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).
Time complexity: O(1)
[中]将字符串值设置为键的值。字符串长度不能超过1073741824字节(1 GB)。
时间复杂度:O(1)
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.set(key, value, params);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.set(key, value);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.set(key, value);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.set(key, value, params);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
public String execute(Jedis connection) {
return connection.set(keyByte, value);
}
}.runBinary(keyByte);
代码示例来源:origin: apache/incubator-dubbo
private void storeMetadata(MetadataIdentifier metadataIdentifier, String v) {
try (Jedis jedis = pool.getResource()) {
jedis.set(metadataIdentifier.getIdentifierKey() + META_DATA_SOTRE_TAG, v);
} catch (Throwable e) {
logger.error("Failed to put " + metadataIdentifier + " to redis " + v + ", cause: " + e.getMessage(), e);
throw new RpcException("Failed to put " + metadataIdentifier + " to redis " + v + ", cause: " + e.getMessage(), e);
}
}
代码示例来源:origin: apache/incubator-dubbo
private void storeMetadata(MetadataIdentifier metadataIdentifier, String v) {
try (Jedis jedis = pool.getResource()) {
jedis.set(metadataIdentifier.getIdentifierKey() + META_DATA_SOTRE_TAG, v);
} catch (Throwable e) {
logger.error("Failed to put " + metadataIdentifier + " to redis " + v + ", cause: " + e.getMessage(), e);
throw new RpcException("Failed to put " + metadataIdentifier + " to redis " + v + ", cause: " + e.getMessage(), e);
}
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String set(byte[] key, byte[] value, SetParams params) {
Jedis j = getShard(key);
return j.set(key, value, params);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String set(String key, String value, SetParams params) {
Jedis j = getShard(key);
return j.set(key, value, params);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String set(String key, String value) {
Jedis j = getShard(key);
return j.set(key, value);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String set(byte[] key, byte[] value) {
Jedis j = getShard(key);
return j.set(key, value);
}
代码示例来源:origin: looly/hutool
/**
* 从Redis中获取值
*
* @param key 键
* @param value 值
* @return 状态码
*/
public String setStr(String key, String value) {
try (Jedis jedis = getJedis()) {
return jedis.set(key, value);
}
}
代码示例来源:origin: looly/hutool
/**
* 从Redis中获取值
*
* @param key 键
* @param value 值
* @return 状态码
*/
public String setStr(String key, String value) {
try (Jedis jedis = getJedis()) {
return jedis.set(key, value);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 String
* @param key
* @param value
*/
public synchronized static void set(String key, String value) {
try {
value = StringUtils.isBlank(value) ? "" : value;
Jedis jedis = getJedis();
jedis.set(key, value);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set key error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 byte[]
* @param key
* @param value
*/
public synchronized static void set(byte[] key, byte[] value) {
try {
Jedis jedis = getJedis();
jedis.set(key, value);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set key error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 byte[] 过期时间
* @param key
* @param value
* @param seconds 以秒为单位
*/
public synchronized static void set(byte[] key, byte[] value, int seconds) {
try {
Jedis jedis = getJedis();
jedis.set(key, value);
jedis.expire(key, seconds);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set key error : " + e);
}
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
SetParams params = SetParams.setParams();
if (expx.equalsIgnoreCase("px")) {
params.px(time);
} else {
params.ex((int) time);
}
return connection.set(keyByte, value, params);
}
}.runBinary(keyByte);
代码示例来源:origin: prestodb/presto
private void populateData(int count)
{
JsonEncoder jsonEncoder = new JsonEncoder();
for (long i = 0; i < count; i++) {
Object value = ImmutableMap.of("id", Long.toString(i), "value", UUID.randomUUID().toString());
try (Jedis jedis = embeddedRedis.getJedisPool().getResource()) {
jedis.set(tableName + ":" + i, jsonEncoder.toString(value));
}
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 存放 key value 对到 redis
* 如果 key 已经持有其他值, SET 就覆写旧值,无视类型。
* 对于某个原本带有生存时间(TTL)的键来说, 当 SET 命令成功在这个键上执行时, 这个键原有的 TTL 将被清除。
*/
public String set(Object key, Object value) {
Jedis jedis = getJedis();
try {
return jedis.set(keyToBytes(key), valueToBytes(value));
}
finally {close(jedis);}
}
代码示例来源: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));
}
}
内容来源于网络,如有侵权,请联系作者删除!