[Node.js]31. Level 7: Redis coming for Node.js, Simple Redis Commands

Let's start practicing using the redis key-value store from our node application. First require the redismodule, and then create a redis client that we can use to call commands on our redis server.

Use the client to set the name key to your name.

var redis = require('redis');
var client = redis.createClient();
client.set("name", "Zhentian");

 

We already have stored a value in the question key. Use the redis client to issue a get command to redis to retrieve and then log the value.

var redis = require('redis');
var client = redis.createClient();
client.get("question", function(err, data){
    console.log(data);    
});

 

posted @ 2014-07-31 23:45  Zhentiw  阅读(136)  评论(0编辑  收藏  举报