////    print_r($field);
//    foreach($field as $_field) {
////        $redis_client = DRedis::getInstance()->getRedisInstance($_field);
////        $value = $key."~".$_field;
////        $redis_client->hSet($key, $_field, $value);
//        $map[$key][] = $_field;
//    }
//}
////print_r($map);
//
//$result = DRedis::getInstance()->hMGetDistriByField($map);
//
//print_r($result);
//for($i= 0 ; $i<30; $i ++) {
//    $key = "f".$i;
//    echo $i."=>" . DRedis::getInstance()->getRedisNode($key) . "\n";
//}
//$dredis = DRedis::getInstance();
//$result = $dredis->mGet($keys);
//
//print_r($result);
$fields = array('view', 'comm', 'prai', 'like');
for ($i = 1; $i <= 380; $i++) {
    $key = "cpost_" . $i;
    foreach ($fields as $field) {
        $rc = DRedis::getInstance()->getRedisInstance($field);
        if ($rc instanceof Redis) {
            $rc->hSet($key, $field, $key . "~" . $field);
        }
    }
}
 /**
  * @param array $key_fields format
  *Array
  *  (
  *      [k_0] => Array
  *      (
  *          [0] => f17
  *          [1] => f19
  *      )
  *
  *      [k_1] => Array
  *      (
  *          [0] => f17
  *          [1] => f18
  *      )
  *
  *      ....
  *
  *      [{key}]=>Array
  *      (
  *           [0] => {field1}
  *           [0] => {field2}
  *      )
  *
  *  )
  *
  *
  * @return array|bool format
  * Array
  *      (
  *          [k_0] => Array
  *          (
  *              [f17] => k_0~f17
  *              [f19] => k_0~f19
  *          )
  *
  *          [k_1] => Array
  *          (
  *              [f17] => k_1~f17
  *              [f18] => k_1~f18
  *          )
  *
  *          ......
  *
  *          [{key}] => Array
  *          (
  *               [{field1}] => [{value1}]
  *               [{field2}] => [{value2}]
  *          )
  *
  *      )
  */
 public function hMGetDistriByField(array $key_fields)
 {
     $node_key_field = array();
     $field_node = array();
     foreach ($key_fields as $key => $fields) {
         foreach ($fields as $field) {
             if (isset($field_node[$field])) {
                 $node = $field_node[$field];
             } else {
                 $node = $this->getRedisNode($field);
                 $field_node[$field] = $node;
             }
             if ($node !== false) {
                 $node_key_field[$node][$key][] = $field;
             }
         }
     }
     if (!empty($node_key_field)) {
         $redis_clients = DRedis::getInstance()->getRedisClients();
         $result = array();
         if (is_array($node_key_field)) {
             foreach ($node_key_field as $_node => $_key_field) {
                 if (!empty($redis_clients[$_node])) {
                     $redis_client = $redis_clients[$_node];
                     $pip_redis_client = new PipRedis($redis_client);
                     $key_fields_values = $pip_redis_client->pipHMGet($_key_field);
                     if (is_array($key_fields_values)) {
                         foreach ($key_fields_values as $key => $field_value) {
                             if (empty($result[$key])) {
                                 $result[$key] = array();
                             }
                             if (!empty($field_value)) {
                                 $result[$key] = $result[$key] + $field_value;
                             }
                         }
                     }
                 }
             }
         }
         return $result;
     } else {
         return false;
     }
 }