本文整理了Java中redis.clients.jedis.Jedis.decrBy()
方法的一些代码示例,展示了Jedis.decrBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.decrBy()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:decrBy
[英]IDECRBY work just like #decr(String) but instead to decrement by 1 the decrement is integer.
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
[中]IDECRBY的工作原理与#decre(String)类似,但要将减量减1,减量是整数。
INCR命令限制为64位有符号整数。
注意:这实际上是一个字符串操作,也就是说,在Redis中没有“整数”类型。只需将存储在密钥处的字符串解析为一个以10为基数的64位有符号整数,递增,然后转换回字符串即可。
时间复杂度:O(1)
代码示例来源:origin: sohutv/cachecloud
@Override
public Long execute(Jedis connection) {
return connection.decrBy(key, integer);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Long execute(Jedis connection) {
return connection.decrBy(key, integer);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Long decrBy(byte[] key, long integer) {
Jedis j = getShard(key);
return j.decrBy(key, integer);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public Long decrBy(String key, long integer) {
Jedis j = getShard(key);
return j.decrBy(key, integer);
}
代码示例来源:origin: Netflix/conductor
@Override
public Long decrBy(String key, long integer) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.decrBy(key, integer);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 将 key 所储存的值减去减量 decrement 。
* 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 DECRBY 操作。
* 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。
* 本操作的值限制在 64 位(bit)有符号数字表示之内。
* 关于更多递增(increment) / 递减(decrement)操作的更多信息,请参见 INCR 命令。
*/
public Long decrBy(Object key, long longValue) {
Jedis jedis = getJedis();
try {
return jedis.decrBy(keyToBytes(key), longValue);
}
finally {close(jedis);}
}
代码示例来源:origin: apache/ignite
try (Jedis jedis = pool.getResource()) {
Assert.assertEquals(2, (long)jedis.incrBy("newKeyIncrBy", 2));
Assert.assertEquals(-2, (long)jedis.decrBy("newKeyDecrBy", 2));
Assert.assertEquals(9L, (long)jedis.decrBy("incrDecrKeyBy", 2));
jedis.decrBy("outOfRangeDecrBy", Long.MIN_VALUE);
jedis.decrBy("outOfRangeDecrBy2", Long.MIN_VALUE);
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long decrBy(byte[] key, long value) {
Assert.notNull(key, "Key must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().decrBy(key, value)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().decrBy(key, value)));
return null;
}
return connection.getJedis().decrBy(key, value);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: jwpttcg66/NettyGameServer
/**
* 返回是否成功
* @param key
* @return
*/
public boolean decrBy(String key, int size){
Jedis jedis = null;
boolean sucess = true;
long result = -1;
try {
jedis = jedisPool.getResource();
jedis.decrBy(key, size);
} catch (Exception e) {
sucess = false;
returnBrokenResource(jedis, "decrBy:"+key, e);
} finally {
if (sucess && jedis != null) {
returnResource(jedis);
}
}
return sucess;
}
public boolean exists(String key){
代码示例来源:origin: tangyanbo/springmore
@Override
public Long action(Jedis jedis) {
return jedis.decrBy(key, decrement);
}
});
代码示例来源:origin: yrain/smart-cache
@Override
Long doInJedis(Jedis jedis) {
return jedis.decrBy(key, value);
}
});
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
return jedis.decrBy(key, integer);
}
});
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long execute(Jedis connection) {
return connection.decrBy(key, decrement);
}
}.run(key);
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long execute(Jedis connection) {
return connection.decrBy(key, decrement);
}
}.runBinary(key);
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-redis
@Override
protected long decrementStorageSize(final long size) {
return redisExecutor.execute((RedisCallable<Long>) jedis -> {
Long decremented = jedis.decrBy(sizeKey, size);
if (log.isDebugEnabled()) {
log.debug(String.format("Decremented Redis key %s to %d", sizeKey, decremented));
}
return decremented;
});
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long decrBy(final String key, final long decrement) {
Jedis j = getShard(key);
return j.decrBy(key, decrement);
}
代码示例来源:origin: com.github.yamingd.argo/argo-redis
public Long execute(final Jedis conn) throws Exception {
return conn.decrBy(SafeEncoder.encode(key), amount);
}
});
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Long decrBy(String key, long integer) {
String command = "decrBy";
return instrumented(command, () -> delegated.decrBy(key, integer));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Long decrBy(byte[] key, long integer) {
String command = "decrBy";
return instrumented(command, () -> delegated.decrBy(key, integer));
}
代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence
@Override
public Long decrBy(String key, long integer) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.decrBy(key, integer);
} finally {
if (jedis != null)
jedis.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!