<commit_before>"use strict";

var cluster = require('cluster'),
	redis = require('redis'),
	_ = require('underscore');

var STORAGE_TYPE= 'storage_type',
	SUPPORT_STORAGE_TYPES = ['HASH', 'STRING', 'SORTEDSET', 'SET'],
	__primary_key__ = '___Id___',
	__value_key__ = ' ___Val___',
	__DBNAME__ = 'db_name';

function Redis(name, options) {
	this.name = name;
	this.host = options.host || 'localhost';
	this.port = options.port || 6379;
	this.password = options.password;
}

Redis.prototype.connect = function (cb) {
	if(this.host && this.port) {
		if(cluster.isMaster) global.gozy.info('Connecting to Redis "' + this.name + '"(' + this.host + ':' + this.port + ' ' + (this.password ? 'with password)' : 'without password)'));
		
		this.redis = redis.createClient(this.port, this.host, null);
		this.redis.on('error', _.bind(function (err) {
			if(err.toString().match(/ETIMEDOUT/)) return this.connect(function () { }); 
			global.gozy.error('error 1');
			global.gozy.error(err);
			
			cb && cb();
		}, this));
		
		var name = this.name;
		
		if(this.password) {
			this.redis.auth(this.password, function(arg) {
				if(cluster.isMaster) global.gozy.info('Successfully connected to ' + name);
				cb && cb();	
			});
			
			setInterval(_.bind(function () {
				this.redis.ping(function () { });
			}, this), 60 * 60 * 1000);
		} else {
			if(cluster.isMaster) global.gozy.info('Successfully connected to ' + name);
			cb && cb();
		}
	} else {
		if(cluster.isMaster) global.gozy.error('Redis connection failed');
		cb && cb();
	}
};

Redis.prototype.clone = function (cb) {
	var _new = new Redis(this.name, {
		host: this.host, 
		port: this.port, 
		password: this.password 	<commit_msg>check "pong" response from redis<commit_after>"use strict";

var cluster = require('cluster'),
	redis = require('redis'),
	_ = require('underscore');

var STORAGE_TYPE= 'storage_type',
	SUPPORT_STORAGE_TYPES = ['HASH', 'STRING', 'SORTEDSET', 'SET'],
	__primary_key__ = '___Id___',
	__value_key__ = ' ___Val___',
	__DBNAME__ = 'db_name';

function Redis(name, options) {
	this.name = name;
	this.host = options.host || 'localhost';
	this.port = options.port || 6379;
	this.password = <PASSWORD>;
}

Redis.prototype.connect = function (cb) {
	if(this.host && this.port) {
		if(cluster.isMaster) global.gozy.info('Connecting to Redis "' + this.name + '"(' + this.host + ':' + this.port + ' ' + (this.password ? 'with password)' : 'without password)'));
		
		this.redis = redis.createClient(this.port, this.host, null);
		this.redis.on('error', _.bind(function (err) {
			if(err.toString().match(/ETIMEDOUT/)) return this.connect(function () { }); 
			global.gozy.error('error 1');
			global.gozy.error(err);
			
			cb && cb();
		}, this));
		
		var name = this.name;
		
		if(this.password) {
			this.redis.auth(this.password, function(arg) {
				if(cluster.isMaster) global.gozy.info('Successfully connected to ' + name);
				cb && cb();	
			});
			
			setInterval(_.bind(function () {
				this.redis.ping(function () { });
			}, this), 60 * 60 * 1000);
		} else {
			this.redis.ping(function (err, pong) {
				if(err && cluster.isMaster) return global.gozy.error('Redis connection failed: ', err);
				if(pong != 'PONG' && cluster.isMaster) return global.gozy.error('Redis connection failed: cannot get PONG');
				
				if(cluster.isMaster) global.gozy.info('Successfully connected to ' + name);
				cb && cb();
			});
		}
	} else {
		if(cluster.isMaster) global.gozy.error('Redis connection failed');
		cb && cb();
	}
};

Redis.prototype.clone = function (cb) {
	var _new = new Redis(this.name, {
		host: this.host, 
		port: this.port, 
		password: <PASSWORD> 	
{'fraction_non_alphanumeric': 0.18278980542614415, 'fraction_numerical': 0.00712523979172376, 'mean_word_length': 3.777486910994764, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '337783', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1291, 'n_words': 255}