Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Created October 30, 2014 03:23
Show Gist options
  • Save JacobHsu/fc5a59ca7abd28c038d2 to your computer and use it in GitHub Desktop.
Save JacobHsu/fc5a59ca7abd28c038d2 to your computer and use it in GitHub Desktop.
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