memcached
Advanced tools
Comparing version 0.0.9 to 0.0.10
var nMemcached = require( '../' ), | ||
memcached; | ||
// connect to a unknown server | ||
memcached = new nMemcached( "10.211.55.5:11211" ); | ||
memcached = new nMemcached( "10.211.55.6:11211" ); | ||
@@ -27,3 +27,3 @@ // each time a server fails | ||
}); | ||
}, 5010 ); | ||
}, 5010 ); |
@@ -1,12 +0,12 @@ | ||
var nMemcached = require( '../' ), | ||
memcached; | ||
var nMemcached = require( '../' ), | ||
memcached; | ||
// connect to our memcached server on host 10.211.55.5, port 11211 | ||
memcached = new nMemcached( "10.211.55.5:11211", { debug: true }); | ||
memcached = new nMemcached( "10.211.55.5:11211" ); | ||
memcached.set( "hello", 1, 10000, function( err, result ){ | ||
if( err ) console.error( err ); | ||
console.dir( result ); | ||
memcached.end(); // as we are 100% certain we are not going to use the connection again, we are going to end it | ||
}); | ||
if( err ) console.error( err ); | ||
console.dir( result ); | ||
memcached.end(); // as we are 100% certain we are not going to use the connection again, we are going to end it | ||
}); |
@@ -135,6 +135,6 @@ "use strict"; | ||
// wait untill the next event loop tick, to try again | ||
process.nextTick(function next () { | ||
Manager.allocate(callback); | ||
}); | ||
// give up and don't saturate the node.js process by retying #43 | ||
var full = new Error("All the connections in the memcached pool are busy"); | ||
full.connectionPool = true; | ||
callback(full); | ||
}; | ||
@@ -145,3 +145,4 @@ | ||
return (readyState === 'open' || readyState === 'writeOnly') | ||
&& !(connection._writeQueue && connection._writeQueue.length); | ||
&& !(connection._writeQueue && connection._writeQueue.length) | ||
&& !(connection._handle && connection._handle.writeQueueSize); | ||
}; | ||
@@ -148,0 +149,0 @@ |
"use strict"; | ||
var createHash = require('crypto').createHash; | ||
var createHash = require('crypto').createHash | ||
, toString = Object.prototype.toString; | ||
exports.validateArg = function validateArg(args, config){ | ||
var toString = Object.prototype.toString | ||
, err | ||
exports.validateArg = function validateArg (args, config) { | ||
var err | ||
, callback; | ||
args.validate.forEach(function(tokens){ | ||
args.validate.forEach(function (tokens) { | ||
var key = tokens[0] | ||
@@ -16,39 +16,61 @@ , value = args[key]; | ||
case Number: | ||
if (toString.call(value) !== '[object Number]') err = 'Argument "' + key + '" is not a valid Number.'; | ||
if (toString.call(value) !== '[object Number]') { | ||
err = 'Argument "' + key + '" is not a valid Number.'; | ||
} | ||
break; | ||
case Boolean: | ||
if (toString.call(value) !== '[object Boolean]') err = 'Argument "' + key + '" is not a valid Boolean.'; | ||
if (toString.call(value) !== '[object Boolean]') { | ||
err = 'Argument "' + key + '" is not a valid Boolean.'; | ||
} | ||
break; | ||
case Array: | ||
if (toString.call(value) !== '[object Array]') err = 'Argument "' + key + '" is not a valid Array.'; | ||
if (toString.call(value) !== '[object Array]') { | ||
err = 'Argument "' + key + '" is not a valid Array.'; | ||
} | ||
break; | ||
case Object: | ||
if (toString.call(value) !== '[object Object]') err = 'Argument "' + key + '" is not a valid Object.'; | ||
if (toString.call(value) !== '[object Object]') { | ||
err = 'Argument "' + key + '" is not a valid Object.'; | ||
} | ||
break; | ||
case Function: | ||
if (toString.call(value) !== '[object Function]') err = 'Argument "' + key + '" is not a valid Function.'; | ||
if (toString.call(value) !== '[object Function]') { | ||
err = 'Argument "' + key + '" is not a valid Function.'; | ||
} | ||
break; | ||
case String: | ||
if (toString.call(value) !== '[object String]') err = 'Argument "' + key + '" is not a valid String.'; | ||
if (toString.call(value) !== '[object String]') { | ||
err = 'Argument "' + key + '" is not a valid String.'; | ||
} | ||
if (!err && key === 'key' && value.length > config.maxKeySize){ | ||
if (config.keyCompression){ | ||
args[key] = createHash('md5').update(value).digest('hex'); | ||
if (!err && key === 'key') { | ||
if (value.length > config.maxKeySize) { | ||
if (config.keyCompression){ | ||
args[key] = createHash('md5').update(value).digest('hex'); | ||
// also make sure you update the command | ||
args.command.replace(value, args[key]); | ||
} else { | ||
err = 'Argument "' + key + '" is longer than the maximum allowed length of ' + config.maxKeySize; | ||
// also make sure you update the command | ||
args.command.replace(value, args[key]); | ||
} else { | ||
err = 'Argument "' + key + '" is longer than the maximum allowed length of ' + config.maxKeySize; | ||
} | ||
} else if (/[\s\n\r]/.test(value)) { | ||
err = 'The key should not contain any whitespace or new lines'; | ||
} | ||
} | ||
break; | ||
default: | ||
if (toString.call(value) === '[object global]' && !tokens[2]) err = 'Argument "' + key + '" is not defined.'; | ||
if (toString.call(value) === '[object global]' && !tokens[2]) { | ||
err = 'Argument "' + key + '" is not defined.'; | ||
} | ||
} | ||
@@ -55,0 +77,0 @@ }); |
{ | ||
"name": "memcached", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"author": { | ||
@@ -49,2 +49,11 @@ "name": "Arnout Kazemier" | ||
{ | ||
"name": "Alfonso Boza" | ||
}, | ||
{ | ||
"name": "Anton Onyshchenko" | ||
}, | ||
{ | ||
"name": "Arek Flinik" | ||
}, | ||
{ | ||
"name": "Arnout Kazemier", | ||
@@ -54,5 +63,8 @@ "email": "info@3rd-Eden.com" | ||
{ | ||
"name": "Anton Onyshchenko" | ||
"name": "Nebojsa Sabovic" | ||
}, | ||
{ | ||
"name": "Tobias Müllerleile" | ||
} | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
260541
51
1579