lib/rts.js
function recordUnique(name, uniqueId, statistics, aggregations, timestamp, callback) {
        timestamp = timestamp || Date.now();
        // normal record
        if(statistics) {
            var num = Array.isArray(uniqueId) ? uniqueId.length : 1;
            record(name, num, statistics, aggregations, timestamp);
        }
        // record unique
        var multi = redis.multi();
        granularities.forEach(function(gran) {
                var key = getGranKey(name, gran, timestamp);
                var expireTime = util.getExpireTime(gran, timestamp);
                var pfkey = key + ':pf';
                multi.hset(keyPFKeys, pfkey, expireTime);
                if(Array.isArray(uniqueId)) {
                    multi.pfadd.apply(multi, [pfkey].concat(uniqueId));
                } else {
                    multi.pfadd(pfkey, uniqueId);
                }
                // recordStats(key);
                var unitPeriod = gran[0];
                multi.hincrby(key, 'uni', 0);
                multi.expire(key, points * unitPeriod / 1000);
        });
        multi.exec(callback || log);
    }
function recordUnique(name, uniqueId, statistics, aggregations, timestamp, callback) {
        timestamp = timestamp || Date.now();
        // normal record
        if(statistics) {
            var num = Array.isArray(uniqueId) ? uniqueId.length : 1;
            record(name, num, statistics, aggregations, timestamp);
        }
        // record unique
        var multi = redis.multi();
        granularities.forEach(function(gran) {
                var key = getGranKey(name, gran, timestamp);
                var expireTime = util.getExpireTime(gran, timestamp);
                var pfkey = key + ':pf';
                multi.hset(keyPFKeys, pfkey, expireTime);
                if(Array.isArray(uniqueId)) {
                    multi.pfadd.apply(multi, [pfkey].concat(uniqueId));
                } else {
                    multi.pfadd(pfkey, uniqueId);
                }
                // recordStats(key);
                var unitPeriod = gran[0];
                multi.hincrby(key, 'uni', 0);
                multi.expire(key, points * unitPeriod / 1000);
        });
        multi.exec(callback || log);
    }
function recordUnique ( name , uniqueId , statistics , aggregations , timestamp , callback ) { timestamp = timestamp || Date . now ( ) ; // normal record if ( statistics ) { var num = Array . isArray ( uniqueId ) ? uniqueId . length : 1 ; record ( name , num , statistics , aggregations , timestamp ) ; } // record unique var multi = redis . multi ( ) ; granularities . forEach ( function ( gran ) { var key = getGranKey ( name , gran , timestamp ) ; var expireTime = util . getExpireTime ( gran , timestamp ) ; var pfkey = key + ':pf' ; multi . hset ( keyPFKeys , pfkey , expireTime ) ; if ( Array . isArray ( uniqueId ) ) { multi . pfadd . apply ( multi , [ pfkey ] . concat ( uniqueId ) ) ; } else { multi . pfadd ( pfkey , uniqueId ) ; } // recordStats(key); var unitPeriod = gran [ 0 ] ; multi . hincrby ( key , 'uni' , 0 ) ; multi . expire ( key , points * unitPeriod / 1000 ) ; } ) ; multi . exec ( callback || log ) ; }
record unique access, like unique user of a period time.
@param {string | Array} uniqueId one or some uniqueId to be stats
record unique access like unique user of a period time .