Permalink
Browse files

Organize things a little.

  • Loading branch information...
1 parent 29f10cd commit 047d367f8cdce67544ba3fdde531bc1f0818267d @mranney mranney committed Sep 24, 2010
File renamed without changes.
@@ -0,0 +1,28 @@
+var redis = require("./index"),
+ client = redis.createClient();
+
+redis.debug_mode = true;
+
+client.on("connect", function () {
+ client.auth("somepass", redis.print);
+
+ client.sadd("bigset", "some shit");
+ client.sadd("bigset", "some other shit");
+ client.sadd("bigset", 1);
+ client.sadd("bigset", 2);
+ client.sadd("bigset", 3);
+ client.sadd("bigset", 4);
+
+ client.multi([
+ ["smembers", ["bigset"], function (err, res) {
+ console.log("1: " + res.toString());
+ }]// ,
+ // ["smembers", ["bigset"], function (err, res) {
+ // console.log("2: " + res.toString());
+ // }],
+ // ["smembers", ["bigset"], function (err, res) {
+ // console.log("3: " + res.toString());
+ // }]
+ ]);
+// client.smembers("bigset", redis.print);
+});
File renamed without changes.
@@ -0,0 +1,40 @@
+var redis = require("./index"),
+ client = redis.createClient(), set_size = 20;
+
+client.sadd("bigset", "a member");
+client.sadd("bigset", "another member");
+
+while (set_size > 0) {
+ client.sadd("bigset", "member " + set_size);
+ set_size -= 1;
+}
+
+// multi chain with an individual callback
+client.multi()
+ .scard("bigset")
+ .smembers("bigset")
+ .keys("*", function (err, replies) {
+ client.mget(replies, redis.print);
+ })
+ .dbsize()
+ .exec(function (err, replies) {
+ console.log("MULTI got " + replies.length + " replies");
+ replies.forEach(function (reply, index) {
+ console.log("Reply " + index + ": " + reply.toString());
+ });
+ });
+
+client.set("incr thing", 100);
+
+// start a separate command queue for multie
+var multi = client.multi();
+multi.incr("incr thing", redis.print);
+multi.incr("incr other thing", redis.print);
+
+// runs immediately
+client.get("incr thing", redis.print); // 100
+
+// drains multi queue and runs atomically
+multi.exec(function (err, replies) {
+ console.log(replies); // 101, 3
+});
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 047d367

Please sign in to comment.