Skip to content

Commit

Permalink
Unpiping the response for ultimate magic
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeix committed Apr 22, 2013
1 parent 406d65a commit 041d992
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"servers": [{
"host": "localhost"
,"port": 6399
,"port": 6379
}
, {
"host": "localhost"
Expand Down
4 changes: 2 additions & 2 deletions lib/redis_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var connectionCommands = ['auth', 'select'];

module.exports = redisCommand = {
readOnly: function(command){
return _.include(readOnlyCommands, command.split("\r\n")[2].toLowerCase());
return _.include(readOnlyCommands, command.split("\r\n")[2]);
}
, connection: function(command){
return _.include(connectionCommands, command.split("\r\n")[2].toLowerCase());
return _.include(connectionCommands, command.split("\r\n")[2]);
}
};
6 changes: 3 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var bindAddress = config.bind_address || "127.0.0.1",


var server = net.createServer(function (socket) {
logger.debug('client connected');
var id = socket.remoteAddress+':'+socket.remotePort
logger.debug('client connected ' + id);
socket.on('end', function() {
logger.info('client disconnected');
// Hack to get the connection identifier, so that we can release the connection
Expand All @@ -28,8 +29,7 @@ var server = net.createServer(function (socket) {
socket.on('data', function(data) {
var command = data.toString('utf8'), id = socket.remoteAddress+':'+socket.remotePort;
redis_proxy.sendCommand(command, id, function(err, response) {
response.removeAllListeners();
logger.debug('got response');
if( response) response.unpipe();
if(err){
return socket.write("-ERR Error Happened "+ err);
}
Expand Down

0 comments on commit 041d992

Please sign in to comment.