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

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

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

Jedis.hmset介绍

[英]Set the respective fields to the respective values. HMSET replaces old values with new values.

If key does not exist, a new key holding a hash is created.

Time complexity: O(N) (with N being the number of fields)
[中]将各个字段设置为各个值。HMSET将旧值替换为新值。
若密钥不存在,则创建一个包含散列的新密钥。
时间复杂度:O(N)(N为字段数)

代码示例

代码示例来源:origin: apache/storm

@Override
public String hmset(String key, Map<String, String> fieldValues) {
  return jedis.hmset(key, fieldValues);
}

代码示例来源:origin: apache/storm

@Override
public String hmset(byte[] key, Map<byte[], byte[]> fieldValues) {
  return jedis.hmset(key, fieldValues);
}

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

@Override
 public String execute(Jedis connection) {
  return connection.hmset(key, hash);
 }
}.run(key);

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

@Override
 public String execute(Jedis connection) {
  return connection.hmset(key, hash);
 }
}.runBinary(key);

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

public String execute(Jedis connection) {
    return connection.hmset(keyByte, hash);
  }
}.runBinary(keyByte);

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

@Override
public String hmset(String key, Map<String, String> hash) {
 Jedis j = getShard(key);
 return j.hmset(key, hash);
}

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

@Override
public String hmset(byte[] key, Map<byte[], byte[]> hash) {
 Jedis j = getShard(key);
 return j.hmset(key, hash);
}

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

@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();
  }
}

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

/**
 * 同时将多个 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);}
}

代码示例来源:origin: caoxinyu/RedisClient

@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);
}

代码示例来源:origin: jooby-project/jooby

@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();
  }
 }
}

代码示例来源:origin: apache/storm

jedis.hmset(description.getAdditionalKey(), keyValues);
if (this.options.expireIntervalSec > 0) {
  jedis.expire(description.getAdditionalKey(), this.options.expireIntervalSec);

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

@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);
  }
}

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

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);
    }
  }
}
/*

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

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;
}

代码示例来源:origin: spinnaker/kayenta

jedis.hmset(mapByApplicationKey, applicationToSerializedCanaryConfigListMap);

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

/**
 * 将对象保存到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;
}
/*

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

@Override
  public Object execute(Jedis jedis) {
    return jedis.hmset(key, hash);
  }
});

代码示例来源:origin: Impetus/Kundera

((Jedis) connection).hmset(getEncodedBytes(redisKey), redisFields);

代码示例来源:origin: xetorthio/rmq

public String hmset(Map<String, String> hash) {
  Jedis jedis = getResource();
  String hmset = jedis.hmset(key(), hash);
  returnResource(jedis);
  return hmset;
}

相关文章

Jedis类方法