/**
  * 通过key同时设置 hash的多个field
  *
  * @param key
  * @param hash
  * @return 返回OK 异常返回null
  */
 public String hmset(String key, Map<String, String> hash) {
   ShardedJedis jedis = null;
   String res = null;
   try {
     jedis = pool.getResource();
     res = jedis.hmset(key, hash);
   } catch (Exception e) {
     pool.returnBrokenResource(jedis);
     e.printStackTrace();
   } finally {
     returnResource(pool, jedis);
   }
   return res;
 }
 public String setMap(String key, Map<String, String> hash) {
   ShardedJedis jedis = null;
   boolean success = true;
   try {
     pool = getPool();
     jedis = pool.getResource();
     return jedis.hmset(key, hash);
   } catch (JedisException e) {
     success = false;
     if (jedis != null) {
       pool.close();
     }
     throw e;
   } finally {
     if (success && jedis != null) {
       pool.close();
     }
   }
 }
 /**
  * Description: <br>
  *
  * @author 王伟<br>
  * @taskId <br>
  * @param nodeName
  * @param node
  * @throws CacheException <br>
  */
 @Override
 public <T> void putNode(String nodeName, Map<String, T> node) throws CacheException {
   if (CommonUtil.isNotEmpty(node)) {
     ShardedJedis shardedJedis = null;
     Map<byte[], byte[]> hmap = new HashMap<byte[], byte[]>();
     try {
       shardedJedis = shardedPool.getResource();
       for (Entry<String, T> entry : node.entrySet()) {
         byte[] value = SerializationUtil.serial(entry.getValue());
         if (value != null) {
           hmap.put(entry.getKey().getBytes(), value);
         }
       }
       shardedJedis.hmset(nodeName.getBytes(), hmap);
     } catch (UtilException e) {
       throw new CacheException(e);
     } catch (Exception e) {
       throw new CacheException(ErrorCodeDef.CACHE_ERROR_10002, "serial map failed!", e);
     } finally {
       shardedPool.returnResourceObject(shardedJedis);
     }
   }
 }