sample/cf-nodejs-shoutboard/web-express.js
function mergeMessages(data) {
    lastSync = (new Date()).getTime();
    if (messages.length == 0) {
        messages = data;
    } else {
        var i = data.length - 1;
        var j = messages.length - 1;
        while (i >= 0 && j >= 0) {
            if (data[i].timestamp < messages[j].timestamp) {
                j--;
            } else {
                messages.splice(j + 1, 0, data[i--]);
            }
        }
    }
}
function mergeMessages(data) {
    lastSync = (new Date()).getTime();
    if (messages.length == 0) {
        messages = data;
    } else {
        var i = data.length - 1;
        var j = messages.length - 1;
        while (i >= 0 && j >= 0) {
            if (data[i].timestamp < messages[j].timestamp) {
                j--;
            } else {
                messages.splice(j + 1, 0, data[i--]);
            }
        }
    }
}
function mergeMessages ( data ) { lastSync = ( new Date ( ) ) . getTime ( ) ; if ( messages . length == 0 ) { messages = data ; } else { var i = data . length - 1 ; var j = messages . length - 1 ; while ( i >= 0 && j >= 0 ) { if ( data [ i ] . timestamp < messages [ j ] . timestamp ) { j -- ; } else { messages . splice ( j + 1 , 0 , data [ i -- ] ) ; } } } }
merge messages from different servers after redis restart
merge messages from different servers after redis restart