我尝试使用Node.js
将数据写入redis客户执行以下操作:
var Redis = require('redis');
var DataStore = function () {
var client = this.redisClient = Redis.createClient();
};
DataStore.prototype.appendObject = function (prefix, key, value, callback) {
// append
return this.redisClient.push(prefix + ':' + key, [JSON.stringify(value)], function (err) {
return callback(err, value);
});
}
在尝试通过调用appendObject来写入数据时,我收到以下错误:
/Users/foobar/code/node_modules/redis/index.js:602
throw err;
^
TypeError: undefined is not a function
at DataStore.appendObject (/Users/foobar/code/lib/data_store.js:41:29)
at /Users/foobar/code/lib/manager.js:52:35
at /Users/foobar/code/lib/data_store.js:31:16
at try_callback (/Users/foobar/code/node_modules/redis/index.js:592:9)
at RedisClient.return_reply (/Users/foobar/code/node_modules/redis/index.js:685:13)
at ReplyParser.<anonymous> (/Users/foobar/code/node_modules/redis/index.js:321:14)
at ReplyParser.emit (events.js:107:17)
at ReplyParser.send_reply (/Users/foobar/code/node_modules/redis/lib/parser/javascript.js:300:10)
at ReplyParser.execute (/Users/foobar/code/node_modules/redis/lib/parser/javascript.js:203:22)
at RedisClient.on_data (/Users/foobar/code/node_modules/redis/index.js:547:27)
Process finished with exit code 1