本文整理了Java中redis.clients.jedis.Jedis.hincrBy()
方法的一些代码示例,展示了Jedis.hincrBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.hincrBy()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:hincrBy
[英]Increment the number stored at field in the hash at key by value. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.
The range of values supported by HINCRBY is limited to 64 bit signed integers.
Time complexity: O(1)
[中]按值递增散列中存储在字段处的数字。若密钥不存在,则创建一个包含散列的新密钥。如果字段不存在或包含字符串,则在应用该操作之前,该值将设置为0。由于value参数是有符号的,所以可以使用此命令执行递增和递减。
HINCRBY支持的值范围限制为64位有符号整数。
时间复杂度:O(1)
代码示例来源:origin: sohutv/cachecloud
@Override
public Long execute(Jedis connection) {
return connection.hincrBy(key, field, value);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Long execute(Jedis connection) {
return connection.hincrBy(key, field, value);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Long hincrBy(byte[] key, byte[] field, long value) {
Jedis j = getShard(key);
return j.hincrBy(key, field, value);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public Long hincrBy(String key, String field, long value) {
Jedis j = getShard(key);
return j.hincrBy(key, field, value);
}
代码示例来源:origin: Netflix/conductor
@Override
public Long hincrBy(String key, String field, long value) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.hincrBy(key, field, value);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 为哈希表 key 中的域 field 的值加上增量 increment 。
* 增量也可以为负数,相当于对给定域进行减法操作。
* 如果 key 不存在,一个新的哈希表被创建并执行 HINCRBY 命令。
* 如果域 field 不存在,那么在执行命令前,域的值被初始化为 0 。
* 对一个储存字符串值的域 field 执行 HINCRBY 命令将造成一个错误。
* 本操作的值被限制在 64 位(bit)有符号数字表示之内。
*/
public Long hincrBy(Object key, Object field, long value) {
Jedis jedis = getJedis();
try {
return jedis.hincrBy(keyToBytes(key), fieldToBytes(field), value);
}
finally {close(jedis);}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long hIncrBy(byte[] key, byte[] field, long delta) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(field, "Field must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hincrBy(key, field, delta)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().hincrBy(key, field, delta)));
return null;
}
return connection.getJedis().hincrBy(key, field, delta);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: jwpttcg66/NettyGameServer
public Long hincrBy(String key,String field,int value){
Jedis jedis = null;
boolean sucess = true;
Long result = -1L;
try{
jedis=jedisPool.getResource();
result = jedis.hincrBy(key, field, value);
}catch (Exception e) {
sucess = false;
returnBrokenResource(jedis, "hincrBy:"+key + ":field"+ field, e);
}finally{
if (sucess && jedis != null) {
returnResource(jedis);
}
}
return result;
}
/**
代码示例来源:origin: tangyanbo/springmore
@Override
public Long action(Jedis jedis) {
return jedis.hincrBy(key, fieldName, increment);
}
});
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long execute(Jedis connection) {
return connection.hincrBy(key, field, value);
}
}.run(key);
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
return jedis.hincrBy(key, field, value);
}
});
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Long hincrBy(String key, String field, long value) {
return jedis.hincrBy(key, field, value);
}
代码示例来源:origin: yrain/smart-cache
@Override
Long doInJedis(Jedis jedis) {
return jedis.hincrBy(key, field, value);
}
});
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long execute(Jedis connection) {
return connection.hincrBy(key, field, value);
}
}.runBinary(key);
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Long hincrBy(String key, String field, long value) {
String command = "hincrBy";
return instrumented(command, () -> delegated.hincrBy(key, field, value));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Long hincrBy(byte[] key, byte[] field, long value) {
String command = "hincrBy";
return instrumented(command, () -> delegated.hincrBy(key, field, value));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long hincrBy(final byte[] key, final byte[] field, final long value) {
Jedis j = getShard(key);
return j.hincrBy(key, field, value);
}
代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence
@Override
public Long hincrBy(String key, String field, long value) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.hincrBy(key, field, value);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: intsmaze/intsmaze
/**
* 更改购物车
*/
@Test
public void editCart(){
//给蜡烛商品项的数量加1
jedis.hincrBy(CART_PRIFIX+"user02", "蜡烛", 1);
jedis.close();
}
代码示例来源:origin: com.github.yamingd.argo/argo-redis
public Long execute(final Jedis conn) throws Exception {
return conn.hincrBy(SafeEncoder.encode(key), SafeEncoder.encode(field), -1 * amount);
}
});
内容来源于网络,如有侵权,请联系作者删除!