Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Apr 4, 2012
1 parent 786b434 commit 84c2f06
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions lib/memcached.js
@@ -1,7 +1,6 @@
var EventEmitter = require('events').EventEmitter
, Stream = require('net').Stream
, Socket = require('net').Socket
, Buffer = require('buffer').Buffer;
, Socket = require('net').Socket;

var HashRing = require('hashring')
, Connection = require('./connection')
Expand All @@ -19,8 +18,6 @@ var HashRing = require('hashring')
*/

function Client(args, options){
if(!(this && this.hasOwnProperty && (this instanceof Client))) this = new Client();

var servers = []
, weights = {}
, key;
Expand All @@ -30,10 +27,12 @@ function Client(args, options){
case '[object String]':
servers.push(args);
break;

case '[object Object]':
weights = args;
servers = Object.keys(args);
case '[object Array]':
break;

default:
servers = args;
break;
Expand All @@ -50,7 +49,7 @@ function Client(args, options){
this.HashRing = new HashRing(args, this.algorithm);
this.connections = {};
this.issues = [];
};
}

// Allows users to configure the memcached globally or per memcached client
Client.config = {
Expand All @@ -73,13 +72,13 @@ Client.config = {

// There some functions we don't want users to touch so we scope them
(function(nMemcached){
const LINEBREAK = '\r\n'
, NOREPLY = ' noreply'
, FLUSH = 1E3
, BUFFER = 1E2
, CONTINUE = 1E1
, FLAG_JSON = 1<<1
, FLAG_BINARY = 2<<1;
var LINEBREAK = '\r\n'
, NOREPLY = ' noreply'
, FLUSH = 1E3
, BUFFER = 1E2
, CONTINUE = 1E1
, FLAG_JSON = 1<<1
, FLAG_BINARY = 2<<1;

var memcached = nMemcached.prototype = new EventEmitter
, private = {}
Expand Down Expand Up @@ -119,11 +118,11 @@ Client.config = {

// Add the event listeners
Utils.fuse(S, {
connect: function streamConnect(){ callback(false, this) }
, close: function streamClose(){ Manager.remove(this) }
, error: function streamError(err){ memcached.connectionIssue(err, S, callback) }
connect: function streamConnect(){ callback(false, this); }
, close: function streamClose(){ Manager.remove(this); }
, error: function streamError(err){ memcached.connectionIssue(err, S, callback); }
, data: Utils.curry(memcached, private.buffer, S)
, timeout: function streamTimeout(){ Manager.remove(this) }
, timeout: function streamTimeout(){ Manager.remove(this); }
, end: S.end
});

Expand Down

0 comments on commit 84c2f06

Please sign in to comment.