本文整理了Java中redis.clients.jedis.Jedis.getSet()
方法的一些代码示例,展示了Jedis.getSet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.getSet()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:getSet
[英]GETSET is an atomic set this value and return the old value command. Set key to the string value and return the old value stored at key. The string can't be longer than 1073741824 bytes (1 GB).
Time complexity: O(1)
[中]GETSET是一个原子集,用于设置此值并返回旧值命令。将key设置为字符串值,并返回存储在key处的旧值。字符串长度不能超过1073741824字节(1 GB)。
时间复杂度:O(1)
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.getSet(key, value);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public byte[] execute(Jedis connection) {
return connection.getSet(key, value);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
public byte[] execute(Jedis connection) {
return connection.getSet(keyByte, value);
}
}.runBinary(keyByte);
代码示例来源:origin: sohutv/cachecloud
@Override
public byte[] getSet(byte[] key, byte[] value) {
Jedis j = getShard(key);
return j.getSet(key, value);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String getSet(String key, String value) {
Jedis j = getShard(key);
return j.getSet(key, value);
}
代码示例来源:origin: qiurunze123/miaosha
public String getset(String key,String value){
Jedis jedis = null;
String result = null;
try {
jedis = jedisPool.getResource();
result = jedis.getSet(key,value);
} catch (Exception e) {
log.error("expire key:{} error",key,e);
jedisPool.returnBrokenResource(jedis);
return result;
}
jedisPool.returnResource(jedis);
return result;
}
/**
代码示例来源:origin: Netflix/conductor
@Override
public String getSet(String key, String value) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.getSet(key, value);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。
* 当 key 存在但不是字符串类型时,返回一个错误。
*/
@SuppressWarnings("unchecked")
public <T> T getSet(Object key, Object value) {
Jedis jedis = getJedis();
try {
return (T)valueFromBytes(jedis.getSet(keyToBytes(key), valueToBytes(value)));
}
finally {close(jedis);}
}
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testGetSet() throws Exception {
try (Jedis jedis = pool.getResource()) {
jcache().put("getSetKey1", "1");
Assert.assertEquals("1", jedis.getSet("getSetKey1", "0"));
Assert.assertNull(jedis.get("getSetNonExistingKey"));
jcache().put("setDataTypeKey", new HashSet<String>(Arrays.asList("1", "2")));
try {
jedis.getSet("setDataTypeKey", "0");
assert false : "Exception has to be thrown!";
}
catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("WRONGTYPE"));
}
}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public byte[] getSet(byte[] key, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().getSet(key, value)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().getSet(key, value)));
return null;
}
return connection.getJedis().getSet(key, value);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public String execute(Jedis connection) {
return connection.getSet(key, value);
}
}.run(key);
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
return jedis.getSet(key, value);
}
});
代码示例来源:origin: tangyanbo/springmore
@Override
public String action(Jedis jedis) {
return jedis.getSet(key, value);
}
});
代码示例来源:origin: com.netflix.dyno/dyno-jedis
@Override
public String execute(Jedis client, ConnectionContext state) throws DynoException {
return client.getSet(key, value);
}
});
代码示例来源:origin: io.leopard/leopard-redis
@Override
public String getSet(String key, String value) {
return jedis.getSet(key, value);
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public String getSet(String key, String value) {
String command = "getSet";
return instrumented(command, payloadSize(value), () -> delegated.getSet(key, value));
}
代码示例来源:origin: com.netflix.dyno/dyno-jedis
@Override
public String execute(Jedis client, ConnectionContext state) throws DynoException {
return decompressValue(client.getSet(key, compressValue(value, state)), state);
}
});
代码示例来源:origin: com.github.yamingd.argo/argo-redis
public String execute(final Jedis conn) throws Exception {
byte[] ret = conn.getSet(SafeEncoder.encode(key), SafeEncoder.encode(value));
if (ret == null){
return null;
}
return SafeEncoder.encode(ret);
}
});
代码示例来源:origin: yangfuhai/jboot
/**
* 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。
* 当 key 存在但不是字符串类型时,返回一个错误。
*/
@SuppressWarnings("unchecked")
public <T> T getSet(Object key, Object value) {
Jedis jedis = getJedis();
try {
return (T) valueFromBytes(jedis.getSet(keyToBytes(key), valueToBytes(value)));
} finally {
returnResource(jedis);
}
}
代码示例来源:origin: com.jfinal/jfinal
/**
* 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。
* 当 key 存在但不是字符串类型时,返回一个错误。
*/
@SuppressWarnings("unchecked")
public <T> T getSet(Object key, Object value) {
Jedis jedis = getJedis();
try {
return (T)valueFromBytes(jedis.getSet(keyToBytes(key), valueToBytes(value)));
}
finally {close(jedis);}
}
内容来源于网络,如有侵权,请联系作者删除!