Giter Site home page Giter Site logo

Comments (7)

mjrusso avatar mjrusso commented on July 20, 2024

Would also like to add that I am running node, post-net2 merge, with the following change to redis-node-client:

diff --git a/redisclient.js b/redisclient.js
index f1dd63f..52ac347 100644
--- a/redisclient.js
+++ b/redisclient.js
@@ -31,7 +31,7 @@

 exports.debugMode = false;

-var tcp = require("tcp"),
+var tcp = require("net"),
     sys = require("sys");

 var CRLF = "\r\n",

from redis-node-client.

fictorial avatar fictorial commented on July 20, 2024

Hi, the initial .get is running before the connection to redis is established. Check out the test.js for this but the idea is client.stream.addListener('connect', function () { client.get(...); });.

To your second comment, I'm bringing this up to speed with net2 based changes in a branch. It will include a parser based on binary buffers which will make this client binary safe. Yay.

from redis-node-client.

mjrusso avatar mjrusso commented on July 20, 2024

Thanks -- works great. I was working off of examples/publisher.js, which doesn't use a listener on the connect event.

re: the binary safe client: I assume that you're addressing the issue I raise below as part of this work, so I won't file another ticket, but just to be clear, code like the following does not work in all scenarios:

if (commandName === 'hgetall' && 
    (reply instanceof MultiBulkReply) &&
    reply.replies.length % 2 === 0) {

    var hash = {};
    for (var i=0; i<reply.replies.length; i += 2) 
        hash[reply.replies[i].value] = maybeAsNumber(reply.replies[i + 1].value);
    return hash;
}

In particular, functions like maybeAsNumber should only be used for purposes like parsing protocol-level status codes. Any other type inference is dangerous, even if slightly un-intuitive. For example, if I use a Redis client lib to write an integer to Redis, I should receive a string value when reading back from Redis. (For more detail, here's the mailing list discussion on the issue: http://groups.google.com/group/redis-db/browse_thread/thread/9888eb9ff383c90c )

from redis-node-client.

fictorial avatar fictorial commented on July 20, 2024

I missed that thread. It does make sense to leave it alone. I am not sure why I thought hashes in particular could be numbers. Weird.

from redis-node-client.

fictorial avatar fictorial commented on July 20, 2024

I'm using maybeAsNumber for INFO, SCARD, ZCARD, and ZSCORE. I believe these to be the appropriate places to interpret the result as a number. Else the value should be left alone as a string.

from redis-node-client.

fictorial avatar fictorial commented on July 20, 2024

BTW I fixed the publisher.js example to be more idiomatic. There was a race condition there. It would wait 1s to issue a command given the setInterval. However, what if the client didn't connect after 1s? Fail. It uses the correct client.stream.addListener idiom now. Thanks for the catch(es)!

from redis-node-client.

mjrusso avatar mjrusso commented on July 20, 2024

Excellent, those changes sound great.

from redis-node-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.