I have installed redis using "npm install redis". Then I run the sample code prodvided by this project page node_redis. I got this
"error error: Redis connection to 127.0.0.1:6379 failed - EPERM, Operation not permitted"
I think I'm missing something here, can someone help me point it out? Below is the code I used
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();
});
node_redis is a package which lets you access Redis from NodeJS, much like MySQL-Python is a package which lets you access MySQL from Python. In both cases you need to have an actual instance of the database (e.g. Redis or MySQL) running for your code to connect to.
You should install Redis (depending on your OS there will be different ways to do this, but on OSX you could run port install redis
or on Ubuntu you could run apt-get install redis-server
or check out the instructions here http://redis.io/download) and then run it with the redis-server
command, which would start up an instance on the default port (6379).
It also looks like there are some Windows builds here: http://code.google.com/p/servicestack/wiki/RedisWindowsDownload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With