Created
October 30, 2014 03:23
-
-
Save JacobHsu/fc5a59ca7abd28c038d2 to your computer and use it in GitHub Desktop.
#nodejs #redis - https://github.com/mranney/node_redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require("redis"), | |
client = redis.createClient(); | |
client.on("error", function (err) { | |
console.log("Error " + err); | |
}); | |
client.set("string key", "string val", redis.print); //Reply: OK | |
client.hset("hash key", "hashtest 1", "some value", redis.print); //Reply: 0 | |
client.hset(["hash key", "hashtest 2", "some other value"], redis.print); //Reply: 0 | |
client.hkeys("hash key", function (err, replies) { | |
console.log( "---------hkeys---------------"); | |
console.log(replies.length + " replies:"); | |
replies.forEach(function (reply, i) { | |
console.log(" " + i + ": " + reply); | |
}); | |
client.quit(); | |
}); | |
client.hgetall("hash key", function (err, obj) { | |
console.log( "---------hgetall--------------"); | |
console.dir(obj); | |
for(var key in obj) { | |
console.log( key+"="+obj[key] ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment