...
 
Commits (6)
node_modules
# Authors of the Memcached project
# Authors and contributors of the Memcached project in alphabetical order
Arnout Kazemier <info@3rd-Eden.com>
Alfonso Boza
Anton Onyshchenko
Arek Flinik
Arnout Kazemier <info@3rd-Eden.com>
Nebojsa Sabovic
Tobias Müllerleile
......@@ -132,16 +132,17 @@ Manager.allocate = function allocate (callback) {
return this.connections.push(this.factory.apply(this, arguments));
}
// 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);
};
Manager.isAvailable = function isAvailable (connection) {
var readyState = connection.readyState;
return (readyState === 'open' || readyState === 'writeOnly')
&& !(connection._writeQueue && connection._writeQueue.length);
&& !(connection._writeQueue && connection._writeQueue.length)
&& !(connection._handle && connection._handle.writeQueueSize);
};
Manager.remove = function remove (connection) {
......
"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]
, value = args[key];
switch(tokens[1]){
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 (!err && key === 'key' && value.length > config.maxKeySize){
if (config.keyCompression){
args[key] = createHash('md5').update(value).digest('hex');
if (toString.call(value) !== '[object String]') {
err = 'Argument "' + key + '" is not a valid String.';
}
// 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;
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;
}
} 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.';
}
}
});
......
{
"name": "memcached"
, "version": "0.0.9"
, "version": "0.0.10"
, "author": "Arnout Kazemier"
, "description": "A fully featured Memcached API client, supporting both single and clustered Memcached servers through consistent hashing and failover/failure. Memcached is rewrite of nMemcached, which will be deprecated in the near future."
, "main": "index"
......