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

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

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

Jedis.hsetnx介绍

[英]Set the specified hash field to the specified value if the field not exists. Time complexity: O(1)
[中]如果指定的哈希字段不存在,请将该字段设置为指定值。时间复杂度:O(1)

代码示例

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

@Override
 public Long execute(Jedis connection) {
  return connection.hsetnx(key, field, value);
 }
}.run(key);

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

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

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

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

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

@Override
public Long hsetnx(String key, String field, String value) {
 Jedis j = getShard(key);
 return j.hsetnx(key, field, value);
}

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

public Long execute(Jedis connection) {
    return connection.hsetnx(keyByte, SafeEncoder.encode(field), value);
  }
}.runBinary(keyByte);

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

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

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

@Override
public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(field, "Field must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().hsetnx(key, field, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().hsetnx(key, field, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().hsetnx(key, field, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: jwpttcg66/NettyGameServer

/**
 * 设置
 * @param key
 * @param value
 * @return
 */
public boolean setHnxString(String key, String field, String value) throws Exception{
  Jedis jedis = null;
  boolean success = true;
  boolean result;
  try {
    jedis = jedisPool.getResource();
    result = (jedis.hsetnx(key, field, value) != 0);
  } catch (Exception e) {
    success = false;
    releasBrokenReidsSource(jedis, key, "setHnxString", e, false);
    throw e;
  } finally {
    releaseReidsSource(success, jedis);
  }
  
  return result;
  
}

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

@Override
  public Object execute(Jedis jedis) {
    return jedis.hsetnx(key, field, value);
  }
});

代码示例来源:origin: yrain/smart-cache

@Override
  Long doInJedis(Jedis jedis) {
    return jedis.hsetnx(key, field, value);
  }
});

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

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

代码示例来源:origin: yrain/smart-cache

@Override
  Long doInJedis(Jedis jedis) {
    return jedis.hsetnx(key, field, value);
  }
});

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

@Override
public Long hsetnx(String key, String field, String value) {
  return jedis.hsetnx(key, field, value);
}

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

@Override
  public Boolean action(Jedis jedis) {
    return jedis.hsetnx(key, fieldName, value) == 1 ? true : false;
  }
});

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

@Override
  public Long execute(final Jedis client, final ConnectionContext state) throws DynoException {
    return client.hsetnx(key, field, compressValue(value, state));
  }
});

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

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

代码示例来源:origin: org.leapframework/jmms-modules-redis

/**
 * Sets the string value of a hash field, only if the field does not exist.
 *
 * <p/>
 * Returns true if the value has been set, returns false if the field already exists.
 */
public Result<Boolean> hsetnx(String key, String field, String value) {
  return exec(redis -> redis.hsetnx(key, field, value) > 0);
}

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

@Override
public Long hsetnx(String key, String field, String value) {
 String command = "hsetnx";
 return instrumented(command, payloadSize(value), () -> delegated.hsetnx(key, field, value));
}

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

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

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

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

相关文章

Jedis类方法