示例#1
0
setInterval(() => {
  const currentSpeed = getCurrentSpeed();
  const currentRPM = getCurrentRPM(currentSpeed);

  redis.lpush(speedListKey, currentSpeed);
  redis.lpush(rpmListKey, currentRPM);

  redis.zincrby(speedSetKey, 1, currentSpeed);
  redis.zincrby(rpmSetKey, 1, currentRPM);
});
示例#2
0
var setNoti = function(data){
	log.info('setNoti',data);
    cluster.hmset('noti', data, function(err, res){
        if(err) log.warn(err);
        else log.info(data);
    });
};
示例#3
0
process.on('SIGINT', () => {
  console.log('\nClosing producer connection');
  kafkaClient.close();
  producer.close();
  redis.disconnect();
  process.exit();
});
示例#4
0
 clear: function () {
     cacheRedis.flushall(function (err) {
         if (err) {
             util.log('cacheHelper.clear', err);
         } else {
             util.log('cacheHelper.clear', 'ok');
         }
     });
 },
示例#5
0
 keys.forEach(function (key) {
     cacheRedis.del(key, function (err) {
         if (err) {
             util.log('cacheHelper.remove', key, err);
         } else {
             callback && callback();
         }
     });
 });
示例#6
0
 _get: function (key, callback) {
     cacheRedis.get(key, function (err, res) {
         if (err) {
             util.log('cacheHelper._get', key, err);
         } else {
             callback && callback(res);
         }
     });
 },
示例#7
0
	cluster.exists('noti', function(err, res){
    	if(res == 1){
    		cluster.hgetall('noti', function(err, res){
		        log.warn(err);
		        socket.emit('getData', {title: res.title, link: res.link});
		    });
    	}else{
    		socket.emit('getData', 	{title: 'not exists', link: 'http://null.com'});
    	}
    });
示例#8
0
 }], (error, data) => {
   if (error) {
     // console.error(`Could not produce message:\n${error}\nRetrying...`);
     tries++;
   } else {
     redis.incr('massproduce');
     success = true;
   }
   callback();
 });
示例#9
0
 set: function (key, value, callback) {
     value = typeof value == 'object' ? JSON.stringify(value) : value;
     cacheRedis.set(key, value, function (err) {
         if (err) {
             util.log('cacheHelper.set', key, err);
         } else {
             util.log('cacheHelper.set', key, value);
             callback && callback();
         }
     });
 },
示例#10
0
setInterval(() => {
  const currentSpeed = getCurrentSpeed();
  const currentRPM = getCurrentRPM(currentSpeed);

  redis.lpush(speedListKey, currentSpeed);
  redis.lpush(rpmListKey, currentRPM);

  redis.zincrby(speedSetKey, 1, currentSpeed);
  redis.zincrby(rpmSetKey, 1, currentRPM);

  redis.publish('lpush', JSON.stringify({
    key: speedSetKey,
    value: currentSpeed
  }));
  redis.publish('lpush', JSON.stringify({
    key: rpmSetKey,
    value: currentRPM
  }));

  redis.publish('zincr', '');
  redis.publish('zincr', '');
});
示例#11
0
  port: 6379,
  host: process.env.REDIS_CONNECTION_2
}, {
  port: 6379,
  host: process.env.REDIS_CONNECTION_3
}, {
  port: 6379,
  host: process.env.REDIS_CONNECTION_4
}, {
  port: 6379,
  host: process.env.REDIS_CONNECTION_5
}, {
  port: 6379,
  host: process.env.REDIS_CONNECTION_6
}];
const redis = new Redis.Cluster(hosts);
redis.set('massproduce', 0);

function guid() {
  function s4() {
    return Math.floor((1 + Math.random()) * 0x10000)
      .toString(16)
      .substring(1);
  }
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
    s4() + '-' + s4() + s4() + s4();
}

let message = '';

function buildMessage(size) {