<commit_before>/**
 * Created by uzysjung on 2016. 3. 16..
 */
'use strict';

const qcClient = require('di-qc-client');
const Pool = require('generic-pool').Pool;
const co = require('co');
const _  = require('underscore');
const internals = {};

exports = module.exports = internals.qcPool = function(option,url,id,pass) {

    var property = {
        name     : 'QueryCache',
        create   : function(callback) {
            co( function*(){
                try {
                    var qc = new qcClient();
                    var connected =  yield qc.open(url, id, pass);

                } catch(e) {
                    callback(e);
                }
                if(connected) {
                    callback(null,qc);
                } else {
                    callback(new Error("qc is not connected"));
                }
            });
        },
        destroy  : function(connection) {
            co(function*(){
                // console.log("QC Pool destroy called");
                yield connection.close();
            }).catch(function(e){
                console.error("QC Pool destroy error occured :",e.stack);
            });
        },
        validate : function(connection) {

            if(connection.connectionError) {
                console.log('error remove on validate');
                return false;
            }
            return true;<commit_msg>Update index.js<commit_after>/**
 * Created by uzysjung on 2016. 3. 16..
 */
'use strict';

const qcClient = require('di-qc-client');
const Pool = require('generic-pool').Pool;
const co = require('co');
const _  = require('underscore');
const internals = {};

exports = module.exports = internals.qcPool = function(option,url,id,pass) {

    var property = {
        name     : 'QueryCache',
        create   : function(callback) {
            co( function*(){
                try {
                    var qc = new qcClient();
                    var connected =  yield qc.open(url, id, pass);

                } catch(e) {
                    callback(e);
                }
                if(connected) {
                    callback(null,qc);
                } else {
                    callback(new Error("qc is not connected"));
                }
            });
        },
        destroy  : function(connection) {
            co(function*(){
                // console.log("QC Pool destroy called");
                yield connection.close();
            }).catch(function(e){
                console.error("QC Pool destroy error occured :",e.stack);
            });
        },
        validate : function(connection) {

            if(connection.connectionError) {
                console.log('error remove on validate',connection.connectionError);
                return false;
            }
            return true;
{'fraction_non_alphanumeric': 0.12504427913567126, 'fraction_numerical': 0.00495926319518243, 'mean_word_length': 1.4136752136752138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6897051', 'n_tokens_mistral': 759, 'n_tokens_neox': 691, 'n_words': 166}