@Override public String hmset(String key, Map<String, String> fieldValues) { return jedisCluster.hmset(key, fieldValues); }
@Override public String hmset(byte[] key, Map<byte[], byte[]> fieldValues) { return jedisCluster.hmset(key, fieldValues); }
@Override public void hMSet(byte[] key, Map<byte[], byte[]> hashes) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(hashes, "Hashes must not be null!"); try { connection.getCluster().hmset(key, hashes); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
/** * {@inheritDoc} */ @Override protected void updateStatesToRedis(Map<String, String> keyValues) { RedisDataTypeDescription description = this.options.dataTypeDescription; switch (description.getDataType()) { case STRING: for (Map.Entry<String, String> kvEntry : keyValues.entrySet()) { if (this.options.expireIntervalSec > 0) { jedisCluster.setex(kvEntry.getKey(), this.options.expireIntervalSec, kvEntry.getValue()); } else { jedisCluster.set(kvEntry.getKey(), kvEntry.getValue()); } } break; case HASH: jedisCluster.hmset(description.getAdditionalKey(), keyValues); if (this.options.expireIntervalSec > 0) { jedisCluster.expire(description.getAdditionalKey(), this.options.expireIntervalSec); } break; default: throw new IllegalArgumentException("Cannot process such data type: " + description.getDataType()); } }
@Override public void run() { jedis.hmset(key, hash); } });
public String hmset(String key, Map<String, String> hash) { return jedisCluster.hmset(key, hash); }
@Override public String hmset(byte[] bytes, Map<byte[], byte[]> map) { return cluster.hmset(bytes, map); }
public String hmset(byte[] key, Map<byte[], byte[]> hash) { return jedisCluster.hmset(key, hash); }
/** * 同时将多个 field-value (域-值)对设置到哈希表 key 中 * 此命令会覆盖哈希表中已存在的域 * 如果 key 不存在,一个空哈希表被创建并执行 HMSET 操作 * @param key * @param fieldValues field,value,field,value.... * @return 如果命令执行成功,返回 OK ,当 key 不是哈希表(hash)类型时,返回一个错误 */ public String hmset(String key,String fieldValues){ String[] fieldValue=fieldValues.split(","); Map<String,String> map=new HashMap<String,String>(); for(int i=0;i<fieldValue.length;i=i+2){ map.put(fieldValue[i],fieldValue[i+1]); } return jedisCluster.hmset(key,map); } /**
@Override public void hMSet(byte[] key, Map<byte[], byte[]> hashes) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(hashes, "Hashes must not be null!"); try { connection.getCluster().hmset(key, hashes); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
/** * 同时将多个 field-value (域-值)对设置到哈希表 key 中。 * 此命令会覆盖哈希表中已存在的域。 * 如果 key 不存在,一个空哈希表被创建并执行 HMSET 操作。 */ public String hmset(Object key, Map<Object, Object> hash) { Map<byte[], byte[]> para = new HashMap<byte[], byte[]>(); for (Entry<Object, Object> e : hash.entrySet()) para.put(valueToBytes(e.getKey()), valueToBytes(e.getValue())); return jedisCluster.hmset(keyToBytes(key), para); }
@Override public void hMSet(byte[] key, Map<byte[], byte[]> hashes) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(hashes, "Hashes must not be null!"); try { connection.getCluster().hmset(key, hashes); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public boolean hmset(final String key, final Map<String, Object> map) { Assert.hasText(key); Assert.notEmpty(map); try { final Map<String, String> newMap = Maps.newHashMap(); map.forEach((field, value) -> newMap.put(field, toJSONString(value))); return isOK(cluster.hmset(key, newMap)); } catch (final Throwable e) { throw new RedisClientException(e.getMessage(), e); } }
/** * 同时将多个 field-value (域-值)对设置到哈希表 key 中。 * 此命令会覆盖哈希表中已存在的域。 * 如果 key 不存在,一个空哈希表被创建并执行 HMSET 操作。 */ public boolean hmset(Object key, Map<?, ?> hash) { if (null == key || null == hash) { return false; } Map<byte[], byte[]> map = Maps.newHashMap(); for (Object field : hash.keySet()) { map.put(serializeKey(field), serializeVal(hash.get(field))); } if (cluster) { return jedisCluster.hmset(serializeKey(key), map).equals("OK"); } else { return jedisOperator.hmset(serializeKey(key), map).equals("OK"); } }
/** * 存储整个role对象 * @author JiangZhiYong * @QQ 359135103 * 2017年9月26日 下午5:06:51 */ public void saveToRedis() { JedisManager.getJedisCluster().hmset(getRoleRedisKey(), JsonUtil.object2Map(this)); } }
/** * 存储角色数据 * * @author JiangZhiYong * @QQ 359135103 2017年8月3日 下午3:22:58 * @param role * * TODO 存储到mongodb */ public void saveRoleData(Role role) { String key = BydrKey.Role_Map.getKey(role.getId()); LOGGER.debug("{}存储数据", key); JedisManager.getJedisCluster().hmset(key, JsonUtil.object2Map(role)); // } }