lib/client.js
function Client(socket, options) {
  options = options || {};

  // hook up subcommand nested properties
  var cmd, sub, method;
  for(cmd in SubCommand) {
    // we have defined the cluster slots subcommand
    // but the cluster command is not returned in the
    // command list, ignore this for the moment
    if(!this[cmd]) continue;

    // must re-define the command method
    // so it is not shared across client instances
    method = this[cmd] = this[cmd].bind(this);

    function subcommand(cmd, sub) {
      var args = [].slice.call(arguments, 1), cb;
      if(typeof args[args.length - 1] === 'function') {
        cb = args.pop();
      }
      this.execute(cmd, args, cb);
      return this;
    }


    for(sub in SubCommand[cmd]) {
      method[sub] = subcommand.bind(this, cmd, sub);
    }
  }

  this.socket = socket;
  this.socket.on('connect', this._connect.bind(this));
  this.socket.on('data', this._data.bind(this));
  this.socket.on('error', this._error.bind(this));
  this.socket.on('close', this._close.bind(this));
  this.tcp = (this.socket instanceof Socket);

  // using a tcp socket connection
  if(this.tcp) {
    this.encoder = new Encoder(
      {return_buffers: options.buffers});
    this.encoder.pipe(this.socket);
    this.decoder = new Decoder(
      {
        simple: options.simple,
        return_buffers: options.buffers,
        raw: options.raw
      });
    this.decoder.on('reply', this._reply.bind(this))
  }
}
function Client(socket, options) {
  options = options || {};

  // hook up subcommand nested properties
  var cmd, sub, method;
  for(cmd in SubCommand) {
    // we have defined the cluster slots subcommand
    // but the cluster command is not returned in the
    // command list, ignore this for the moment
    if(!this[cmd]) continue;

    // must re-define the command method
    // so it is not shared across client instances
    method = this[cmd] = this[cmd].bind(this);

    function subcommand(cmd, sub) {
      var args = [].slice.call(arguments, 1), cb;
      if(typeof args[args.length - 1] === 'function') {
        cb = args.pop();
      }
      this.execute(cmd, args, cb);
      return this;
    }


    for(sub in SubCommand[cmd]) {
      method[sub] = subcommand.bind(this, cmd, sub);
    }
  }

  this.socket = socket;
  this.socket.on('connect', this._connect.bind(this));
  this.socket.on('data', this._data.bind(this));
  this.socket.on('error', this._error.bind(this));
  this.socket.on('close', this._close.bind(this));
  this.tcp = (this.socket instanceof Socket);

  // using a tcp socket connection
  if(this.tcp) {
    this.encoder = new Encoder(
      {return_buffers: options.buffers});
    this.encoder.pipe(this.socket);
    this.decoder = new Decoder(
      {
        simple: options.simple,
        return_buffers: options.buffers,
        raw: options.raw
      });
    this.decoder.on('reply', this._reply.bind(this))
  }
}
function Client ( socket , options ) { options = options || { } ; // hook up subcommand nested properties var cmd , sub , method ; for ( cmd in SubCommand ) { // we have defined the cluster slots subcommand // but the cluster command is not returned in the // command list, ignore this for the moment if ( ! this [ cmd ] ) continue ; // must re-define the command method // so it is not shared across client instances method = this [ cmd ] = this [ cmd ] . bind ( this ) ; function subcommand ( cmd , sub ) { var args = [ ] . slice . call ( arguments , 1 ) , cb ; if ( typeof args [ args . length - 1 ] === 'function' ) { cb = args . pop ( ) ; } this . execute ( cmd , args , cb ) ; return this ; } for ( sub in SubCommand [ cmd ] ) { method [ sub ] = subcommand . bind ( this , cmd , sub ) ; } } this . socket = socket ; this . socket . on ( 'connect' , this . _connect . bind ( this ) ) ; this . socket . on ( 'data' , this . _data . bind ( this ) ) ; this . socket . on ( 'error' , this . _error . bind ( this ) ) ; this . socket . on ( 'close' , this . _close . bind ( this ) ) ; this . tcp = ( this . socket instanceof Socket ) ; // using a tcp socket connection if ( this . tcp ) { this . encoder = new Encoder ( { return_buffers : options . buffers } ) ; this . encoder . pipe ( this . socket ) ; this . decoder = new Decoder ( { simple : options . simple , return_buffers : options . buffers , raw : options . raw } ) ; this . decoder . on ( 'reply' , this . _reply . bind ( this ) ) } }
Represents a redis client connection.

@param socket The underlying socket.
@param options Client connection options.
Represents a redis client connection .