redis.clients.jedis.Jedis.hincrByFloat()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中redis.clients.jedis.Jedis.hincrByFloat()方法的一些代码示例,展示了Jedis.hincrByFloat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.hincrByFloat()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:hincrByFloat

Jedis.hincrByFloat介绍

[英]Increment the number stored at field in the hash at key by a double precision floating point 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 HINCRBYFLOAT is limited to double precision floating point values.

Time complexity: O(1)
[中]将散列at键中存储于字段的数字增加一个双精度浮点值。若密钥不存在,则创建一个包含散列的新密钥。如果字段不存在或包含字符串,则在应用该操作之前,该值将设置为0。由于value参数是有符号的,所以可以使用此命令执行递增和递减。
HINCRBYFLOAT支持的值范围仅限于双精度浮点值。
时间复杂度:O(1)

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
 public Double execute(Jedis connection) {
  return connection.hincrByFloat(key, field, value);
 }
}.runBinary(key);

代码示例来源:origin: sohutv/cachecloud

@Override
public Double hincrByFloat(String key, String field, double value) {
 Jedis j = getShard(key);
 return j.hincrByFloat(key, field, value);
}

代码示例来源:origin: sohutv/cachecloud

@Override
public Double hincrByFloat(byte[] key, byte[] field, double value) {
 Jedis j = getShard(key);
 return j.hincrByFloat(key, field, value);
}

代码示例来源:origin: Netflix/conductor

@Override
public Double hincrByFloat(String key, String field, double value) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.hincrByFloat(key, field, value);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

代码示例来源:origin: jfinal/jfinal

/**
 * 为哈希表 key 中的域 field 加上浮点数增量 increment 。
 * 如果哈希表中没有域 field ,那么 HINCRBYFLOAT 会先将域 field 的值设为 0 ,然后再执行加法操作。
 * 如果键 key 不存在,那么 HINCRBYFLOAT 会先创建一个哈希表,再创建域 field ,最后再执行加法操作。
 * 当以下任意一个条件发生时,返回一个错误:
 * 1:域 field 的值不是字符串类型(因为 redis 中的数字和浮点数都以字符串的形式保存,所以它们都属于字符串类型)
 * 2:域 field 当前的值或给定的增量 increment 不能解释(parse)为双精度浮点数(double precision floating point number)
 * HINCRBYFLOAT 命令的详细功能和 INCRBYFLOAT 命令类似,请查看 INCRBYFLOAT 命令获取更多相关信息。
 */
public Double hincrByFloat(Object key, Object field, double value) {
  Jedis jedis = getJedis();
  try {
    return jedis.hincrByFloat(keyToBytes(key), fieldToBytes(field), value);
  }
  finally {close(jedis);}
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Double hIncrBy(byte[] key, byte[] field, double 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().hincrByFloat(key, field, delta)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().hincrByFloat(key, field, delta)));
      return null;
    }
    return connection.getJedis().hincrByFloat(key, field, delta);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
 public Double execute(Jedis connection) {
  return connection.hincrByFloat(key, field, value);
 }
}.runBinary(key);

代码示例来源:origin: tangyanbo/springmore

@Override
  public Double action(Jedis jedis) {
    return jedis.hincrByFloat(key, fieldName, increment);
  }
});

代码示例来源:origin: com.netflix.dyno/dyno-jedis

@Override
public Double execute(Jedis client, ConnectionContext state) {
  return client.hincrByFloat(key, field, value);
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
public Double hincrByFloat(String key, String field, double value) {
  return jedis.hincrByFloat(key, field, value);
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
public Double hincrByFloat(String key, String field, double value) {
  return jedis.hincrByFloat(key, field, value);
}

代码示例来源:origin: mindwind/craft-atom

private Double hincrbyfloat0(Jedis j, String key, String field, double increment) {
  return j.hincrByFloat(key, field, increment);
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public Double hincrByFloat(String key, String field, double value) {
  return master.hincrByFloat(key, field, value);
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Double hincrByFloat(String key, String field, double value) {
 String command = "hincrByFloat";
 return instrumented(command, () -> delegated.hincrByFloat(key, field, value));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Double hincrByFloat(byte[] key, byte[] field, double value) {
 String command = "hincrByFloat";
 return instrumented(command, () -> delegated.hincrByFloat(key, field, value));
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Double hincrByFloat(final String key, final String field, final double value) {
 Jedis j = getShard(key);
 return j.hincrByFloat(key, field, value);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Double hincrByFloat(final byte[] key, final byte[] field, final double value) {
 Jedis j = getShard(key);
 return j.hincrByFloat(key, field, value);
}

代码示例来源:origin: io.enoa/nosql-redis

default Double hincrbyfloat(String key, String field, double value) {
 return this.run((jedis, serializer) -> jedis.hincrByFloat(key, field, value));
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public Double hincrByFloat(String key, String field, double value) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.hincrByFloat(key, field, value);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

代码示例来源:origin: com.jfinal/jfinal

/**
 * 为哈希表 key 中的域 field 加上浮点数增量 increment 。
 * 如果哈希表中没有域 field ,那么 HINCRBYFLOAT 会先将域 field 的值设为 0 ,然后再执行加法操作。
 * 如果键 key 不存在,那么 HINCRBYFLOAT 会先创建一个哈希表,再创建域 field ,最后再执行加法操作。
 * 当以下任意一个条件发生时,返回一个错误:
 * 1:域 field 的值不是字符串类型(因为 redis 中的数字和浮点数都以字符串的形式保存,所以它们都属于字符串类型)
 * 2:域 field 当前的值或给定的增量 increment 不能解释(parse)为双精度浮点数(double precision floating point number)
 * HINCRBYFLOAT 命令的详细功能和 INCRBYFLOAT 命令类似,请查看 INCRBYFLOAT 命令获取更多相关信息。
 */
public Double hincrByFloat(Object key, Object field, double value) {
  Jedis jedis = getJedis();
  try {
    return jedis.hincrByFloat(keyToBytes(key), fieldToBytes(field), value);
  }
  finally {close(jedis);}
}

相关文章

微信公众号

最新文章

更多

Jedis类方法