@Override public String hmset(String key, Map<String, String> fieldValues) { return jedis.hmset(key, fieldValues); }
@Override public String hmset(byte[] key, Map<byte[], byte[]> fieldValues) { return jedis.hmset(key, fieldValues); }
@Override public String execute(Jedis connection) { return connection.hmset(key, hash); } }.run(key);
@Override public String execute(Jedis connection) { return connection.hmset(key, hash); } }.runBinary(key);
public String execute(Jedis connection) { return connection.hmset(keyByte, hash); } }.runBinary(keyByte);
@Override public String hmset(String key, Map<String, String> hash) { Jedis j = getShard(key); return j.hmset(key, hash); }
@Override public String hmset(byte[] key, Map<byte[], byte[]> hash) { Jedis j = getShard(key); return j.hmset(key, hash); }
@Override public String hmset(String key, Map<String, String> hash) { Jedis jedis = null; try { jedis = jedisPool.getResource(); return jedis.hmset(key, hash); } finally { if (jedis != null) jedis.close(); } }
/** * 同时将多个 field-value (域-值)对设置到哈希表 key 中。 * 此命令会覆盖哈希表中已存在的域。 * 如果 key 不存在,一个空哈希表被创建并执行 HMSET 操作。 */ public String hmset(Object key, Map<Object, Object> hash) { Jedis jedis = getJedis(); try { Map<byte[], byte[]> para = new HashMap<byte[], byte[]>(); for (Entry<Object, Object> e : hash.entrySet()) para.put(fieldToBytes(e.getKey()), valueToBytes(e.getValue())); return jedis.hmset(keyToBytes(key), para); } finally {close(jedis);} }
@Override protected void command() { jedis.select(db); if(jedis.exists(key) && getValueType(key) != NodeType.HASH) throw new RuntimeException(RedisClient.i18nFile.getText(I18nFile.HASHEXIST)+ key); jedis.hmset(key, values); }
@Override public void save(final Session session) { Jedis jedis = null; try { jedis = pool.getResource(); String key = key(session); Map<String, String> attrs = new HashMap<>(session.attributes()); attrs.put("_createdAt", Long.toString(session.createdAt())); attrs.put("_accessedAt", Long.toString(session.accessedAt())); attrs.put("_savedAt", Long.toString(session.savedAt())); jedis.hmset(key, attrs); if (timeout > 0) { jedis.expire(key, timeout); } } finally { if (jedis != null) { jedis.close(); } } }
jedis.hmset(description.getAdditionalKey(), keyValues); if (this.options.expireIntervalSec > 0) { jedis.expire(description.getAdditionalKey(), this.options.expireIntervalSec);
@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 { if (isPipelined()) { pipeline(connection.newStatusResult(connection.getRequiredPipeline().hmset(key, hashes))); return; } if (isQueueing()) { transaction(connection.newStatusResult(connection.getRequiredTransaction().hmset(key, hashes))); return; } connection.getJedis().hmset(key, hashes); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
public void updateObjectHashMap(String key,Map<String,Object> map){ Jedis jedis = null; boolean sucess = true; try{ Map<String,String> mapToUpdate=new HashMap<String, String>(); for(Entry<String, Object> entry:map.entrySet()){ String temp=entry.getKey(); Object obj=entry.getValue(); if(obj instanceof Date){ mapToUpdate.put(temp, TimeUtils.dateToString((Date)obj)); }else{ mapToUpdate.put(temp, obj.toString()); } } jedis=jedisPool.getResource(); jedis.hmset(key, mapToUpdate); }catch (Exception e) { sucess = false; returnBrokenResource(jedis, "updateHashMap:"+key, e); }finally{ if (sucess && jedis != null) { returnResource(jedis); } } } /*
public boolean setListToHash(String key,List<RedisListInterface> list,int seconds){ Jedis jedis = null; boolean sucess = true; try { Map<String,String> map=new HashMap<String, String>(); Map<String,String> keyMap=null; String[] keyNames=null; for(RedisListInterface po:list){ map.put(po.getSubUniqueKey(), JsonUtils.getJsonStr(EntityUtils.getCacheValueMap((IEntity) po))); } jedis=jedisPool.getResource(); jedis.hmset(key, map); if(seconds >= 0){ jedis.expire(key, seconds); } } catch (Exception e) { sucess = false; returnBrokenResource(jedis, "setListToHash:"+key, e); } finally { if (sucess && jedis != null) { returnResource(jedis); } } return sucess; }
jedis.hmset(mapByApplicationKey, applicationToSerializedCanaryConfigListMap);
/** * 将对象保存到hash中,并且设置生命周期 * @param key * @param entity * @param seconds */ public boolean setObjectToHash(String key,IEntity entity,int seconds){ Jedis jedis = null; boolean sucess = true; try{ jedis=jedisPool.getResource(); Map<String, String> map = EntityUtils.getCacheValueMap(entity); jedis.hmset(key, map); if(seconds>=0){ jedis.expire(key, seconds); } }catch (Exception e) { sucess = false; returnBrokenResource(jedis, "setObjectToHash:"+key, e); }finally{ if (sucess && jedis != null) { returnResource(jedis); } } return sucess; } /*
@Override public Object execute(Jedis jedis) { return jedis.hmset(key, hash); } });
((Jedis) connection).hmset(getEncodedBytes(redisKey), redisFields);
public String hmset(Map<String, String> hash) { Jedis jedis = getResource(); String hmset = jedis.hmset(key(), hash); returnResource(jedis); return hmset; }