我使用"npm install redis"安装了redis.然后我运行这个项目页面node_redis产生的示例代码.我懂了
"error error: Redis connection to 127.0.0.1:6379 failed - EPERM, Operation not permitted"
Run Code Online (Sandbox Code Playgroud)
我想我在这里错过了一些东西,有人可以帮我指出来吗?以下是我使用的代码
var redis = require("redis"),
client = redis.createClient();
client.on("error", function (err){
console.log("Error " + err);
});
client.set("string key", "string val", redis.print);
client.hset("hash key", "hashtest 1", "some value", redis.print);
client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
client.hkeys("hash key", function (err, replies) {
console.log(replies.length + " replies:");
replies.forEach(function (reply, i) {
console.log(" " + i + ": " + reply);
});
client.quit();
});
Run Code Online (Sandbox Code Playgroud)
nic*_*ten 12
node_redis是一个允许您从NodeJS访问Redis的包,就像MySQL-Python是一个允许您从Python访问MySQL的包.在这两种情况下,您都需要运行数据库的实际实例(例如Redis或MySQL)才能连接到您的代码.
您应该安装Redis(取决于您的操作系统,将有不同的方法来执行此操作,但在OSX上您可以运行port install redis或在Ubuntu上运行apt-get install redis-server或查看此处的说明http://redis.io/download)然后运行它使用该redis-server命令,它将在默认端口(6379)上启动实例.
它看起来似乎还有一些Windows版本:http://code.google.com/p/servicestack/wiki/RedisWindowsDownload
对于Windows用户,
从这里下载redis-server. https://github.com/dmajkic/redis/downloads
这对我有用,但我仍然在寻找一个托管redis数据库的方法.
| 归档时间: |
|
| 查看次数: |
9956 次 |
| 最近记录: |