This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ispsArr = mysql.IspWhitelist.findAll({ | |
| where:{iso_code:'GB'}, | |
| attributes: ['isp_name'], | |
| }).then((isps) => { | |
| let ispsArr=[]; | |
| isps.forEach(function(isp) { | |
| ispsArr.push(isp.isp_name) | |
| }) | |
| //console.log(ispsArr) | |
| return ispsArr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let ispsArr = mysql.IspWhitelist.findAll({ | |
| where:{iso_code:'GB'}, | |
| attributes: ['isp_name'], | |
| }).then((isps) => { | |
| let ispsArr=[]; | |
| isps.forEach(function(isp) { | |
| ispsArr.push(isp.isp_name) | |
| }) | |
| console.log(ispsArr) //Gives me the array | |
| return ispsArr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var maxmind = require('maxmind'); | |
| const Promise = require('bluebird'); | |
| const geoip = {}; | |
| Promise.promisifyAll(maxmind); | |
| geoip.userGeoInfo = function () { | |
| //Async db calls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { action_id: 53510, | |
| action_code: 'https://tracking.crobo.com/aff_c?offer_id=29257&aff_id=19699', | |
| network_id: 1052, | |
| action_subid: 'UK-TTT5_17822', | |
| random_ref: 1, | |
| idfa_gaid: 1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql.MobileAction.findOne({ where: {action_id: req.query.D} }).then(function(action) { | |
| cache.remember('key1', 600, function() { | |
| return Promise.resolve(action); | |
| }).then((val) => { | |
| console.log('set: ', val); | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| return Promise.try(() => { | |
| return memcached.getAsync(key); | |
| }).then((value) => { | |
| if (value !== undefined) { | |
| console.log('exists'); | |
| return value; | |
| } else { | |
| return Promise.try(() => { | |
| if (typeof callback === "function") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val = cache.remember('key','value1',600,function(){ | |
| return 'value2'; | |
| }); | |
| console.log('set: '+val) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| return Promise.try(() => { | |
| return memcached.getAsync(key); | |
| }).then((value) => { | |
| if (value !== undefined) { | |
| return value; | |
| } else { | |
| return Promise.try(() => { | |
| return callback() | |
| }).then((value) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cache.remember = function (key, lifetime, callback) { | |
| memcached.get(key, function (err, data) { | |
| if(data){ | |
| return data; | |
| } | |
| }); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Memcached = require('memcached'); | |
| const memcached = new Memcached('server.com:11211'); | |
| memcached.on('issue', details => console.log('issue: ', details)) | |
| memcached.on('failure', details => console.log('failure: ', details)) | |
| memcached.on('reconnecting', details => console.log('reconnecting: ', details)) | |
| memcached.on('reconnect', details => console.log('reconnect: ', details)) | |
| memcached.on('remove', details => console.log('remove: ', details)) | |
| const Cache = {} |