English 中文(简体)
Parse Redis HGETALL Object in Node.js
原标题:Parse Redis HGETALL object in Node.js

I m 试图在Node.js 取缔HGETALL物体。


In Redis CLI:

> HGETALL userList

回返

1) "19578616521094096601"
2) "User 1"
3) "1682930884780137383"
4) "User 2"

Node:

var redis = require( redis )
,   r = redis.createClient();

console.log(r.HGETALL( userList ));

回返

true

我愿把用户语言作为“JSON”或一个阵列,但我看不出如何从中提取数据。

最佳回答

RedisClient use callsback to Return the result.

实例:

var redis = require( redis ),
    r = redis.createClient();

r.hgetall( userList , function(err, results) {
   if (err) {
       // do something like callback(err) or whatever
   } else {
      // do something with results
      console.log(results)
   }
});
问题回答

暂无回答




相关问题
How do you mix SQL DB vs. Key-Value store (i.e. Redis)

I m reviewing my code and realize I spend a tremendous amount of time taking rows from a database, formatting as XML, AJAX GET to browser, and then converting back into a hashed javascript object ...

Predis sharding (consistent hashing)

Predis claim to have Client-side sharding (support for consistent hashing of keys). http://github.com/nrk/predis I can do sharding using connect to an array of profiles (nodes) but it isn t ...

key value stores for extendable objects

http://www.infoq.com/presentations/newport-evolving-key-value-programming-model is a video about KV stores, and the whole premise is that redis promotes a column-based style for storing the attributes ...

nginx/redis and handling tracking params in url

I am using nginx and redis in my website. For several items on my site, I want to add tracking params to their urls so that when a user clicks on an item, I can collect statistics of user usage apart ...

热门标签