utils/trackedUsersCache.js
function has(id, cb) {
        // Do we have it in the local cache?
        if (sessionIdCache[id]) {
            cb(true);
        }

        // Looking in the database
        else {
            db.collection('trackedUsersCache').find({
                    _id: id
                })
                .toArray((err, docs) => {
                    if (errorHandler.dbErrorCatcher(err)) { return; }

                    // We did not find anything
                    if (!docs || docs.length < 1) {
                        cb(false);
                    }

                    // We found it. Let's cache it and return true
                    else {
                        sessionIdCache[id] = docs[0].info;
                        cb(true);
                    }
                });
        }
    }
function has(id, cb) {
        // Do we have it in the local cache?
        if (sessionIdCache[id]) {
            cb(true);
        }

        // Looking in the database
        else {
            db.collection('trackedUsersCache').find({
                    _id: id
                })
                .toArray((err, docs) => {
                    if (errorHandler.dbErrorCatcher(err)) { return; }

                    // We did not find anything
                    if (!docs || docs.length < 1) {
                        cb(false);
                    }

                    // We found it. Let's cache it and return true
                    else {
                        sessionIdCache[id] = docs[0].info;
                        cb(true);
                    }
                });
        }
    }
function has ( id , cb ) { // Do we have it in the local cache? if ( sessionIdCache [ id ] ) { cb ( true ) ; } // Looking in the database else { db . collection ( 'trackedUsersCache' ) . find ( { _id : id } ) . toArray ( ( err , docs ) => { if ( errorHandler . dbErrorCatcher ( err ) ) { return ; } // We did not find anything if ( ! docs || docs . length < 1 ) { cb ( false ) ; } // We found it. Let's cache it and return true else { sessionIdCache [ id ] = docs [ 0 ] . info ; cb ( true ) ; } } ) ; } }
Do we have this user's information recorded? If yes, we already tracked it at least once
Do we have this user s information recorded? If yes we already tracked it at least once