code: function getStat(type, name, granCode, fromDate, toDate, callback) {
          if(!granCode) throw new Error('granCode is required');
          if(!callback && typeof toDate == 'function') {
              callback = toDate;
              toDate = Date.now();
          }
          var gran = granMap[granCode] || util.getUnitDesc(granCode);
          if(!gran) throw new Error('Granualrity is not defined ' + granCode);
          if(fromDate instanceof Date) fromDate = fromDate.getTime();
          if(toDate instanceof Date) toDate = toDate.getTime();
  
          toDate = toDate || Date.now()
          fromDate = fromDate || (toDate - util.getTimePeriod(gran, points));
  
          var unitPeriod = gran[0];
          var multi = redis.multi();
          var _points = [];
          for(var d = fromDate; d <= toDate; d += unitPeriod) {
              var key = getGranKey(name, gran, d);
              _points.push(util.getKeyTime(gran, d));
              multi.hget(key, type);
          }
          multi.exec(function(err, results) {
                  if(err) return callback(err);
                  var merged = [];
                  for (var i = 0, l = _points.length, p; i < l; i ++) {
                      p = _points[i];
                      merged[i] = [p, Number(results[i])];
                  }
                  callback(null, {
                          step: unitPeriod
                        , unitType: gran[3]
                        , data: merged
                  });
          });
      }
docs: get results of the stats
  
  @param {String} type sum, min, max, avg, count, uni