othiym23 / cls-redis

9 stars 8 forks source link

One possible alternative #1

Open brycebaril opened 11 years ago

brycebaril commented 11 years ago

This isn't anything you don't know, but I find it nice to have it in front of me to reference. The flow of a typical command is (using get in this example):

client.get(..., callback)
  -> send_command (creates a "Command" instance containing callback, stuffs it onto command_queue)
    -> pipelined out to the socket

socket reply
  -> parser
    -> return_reply return_error (gets Callback instance from command_queue)
      -> try_callback
        -> callback
   or
    -> return_error
      -> callback

I haven't tried this, but one possible alternative approach would be to have node_redis expose the Command type, and the wrapper could modify or provide an alternate Command type that does the wrapping vs wrapping send_command.

I don't know if it is any better, but at the very least it would save the args sniffing.

othiym23 commented 11 years ago

That would be awesome! I have to keep the current approach around as a shim (because polyfills like this aren't super useful if they dictate a minimum version of the thing they're patching), but anything that saved cycles on hot paths would be useful.