Comments (7)
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.
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.
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.
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.
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.
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.
Excellent, those changes sound great.
from redis-node-client.
Related Issues (20)
- Can't figure out how this is supposed to work without some ugly code HOT 4
- npm HOT 4
- client.get -> TypeError: Cannot read property 'length' of undefined HOT 9
- Operations returning empty lists/sets should return [] instead of null
- TypeError: Cannot read property 'length' of null HOT 4
- Register package with npm HOT 1
- Compatible with node v0.1.100 ? HOT 4
- HSETNX HOT 3
- ./index.js HOT 3
- Register package with NPM HOT 4
- node test/test.js -q FAILED (nodejs 0.1.102 + redis 1.3.17 + redis-node 0.3.5) HOT 5
- non-standard intepretation of trailing commas
- Are command arguments sanitized? HOT 1
- Incompatible with latest Node HOT 3
- test/test.js throwing has no method 'utf8Write' error HOT 10
- "testZINTER" "ERR unknown command 'zinter'" HOT 1
- "ERR unknown command '*2"
- Cannot read property 'length' of undefined HOT 3
- "noconnection" event not emitted if Redis goes away after the first connection
- Server never calls back on Node 0.2.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redis-node-client.