@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 { return JedisConverters.toBoolean(connection.getCluster().hsetnx(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long hsetnx(byte[] bytes, byte[] bytes1, byte[] bytes2) { return cluster.hsetnx(bytes, bytes1, bytes2); }
/** * 将哈希表 key 中的域 field 的值设置为 value ,当且仅当域 field 不存在 * 若域 field 已经存在,该操作无效 * 如果 key 不存在,一个新哈希表被创建并执行 HSETNX 命令 * @param key * @param field * @param value * @return 设置成功,返回 1 ,如果给定域已经存在且没有操作被执行,返回 0 */ public Long hsetnx(String key,String field,String value){ return jedisCluster.hsetnx(key, field, value); } /**
public Long hsetnx(String key, String field, String value) { return jedisCluster.hsetnx(key, field, value); }
public Long hsetnx(byte[] key, byte[] field, byte[] value) { return jedisCluster.hsetnx(key, field, value); }
@Override public boolean setHnxString(String key, String field, String value) throws Exception { boolean flag = false; try { flag = (jedisCluster.hsetnx(key, field, value) != 0); } catch (Exception e) { logger.error(TimeUtil.getDateString(new Date()) + ":::::" + "setNxString" + key, e); } return flag; }
@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 { return JedisConverters.toBoolean(connection.getCluster().hsetnx(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@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 { return JedisConverters.toBoolean(connection.getCluster().hsetnx(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public boolean hsetByNX(final String key, final String field, final String value) { Assert.hasText(key); Assert.hasText(field); Assert.hasText(value); try { return isSuccess(cluster.hsetnx(key, field, value)); } catch (final Throwable e) { throw new RedisClientException(e.getMessage(), e); } }
/** * hash.设值 * 如果key不存在,则新建.返回1 * 如果key存在,则取消新建,返回0 */ public boolean hsetnx(Object key, Object field, Object value) { if (null == key || null == field || null == value) { return false; } if (cluster) { return jedisCluster.hsetnx(serializeKey(key), serializeKey(field), serializeVal(value)) == 1; } else { return jedisOperator.hsetnx(serializeKey(key), serializeKey(field), serializeVal(value)) == 1; } }