Skip to content

Instantly share code, notes, and snippets.

@jhs
Created August 4, 2012 02:00
Show Gist options
  • Save jhs/3253501 to your computer and use it in GitHub Desktop.
Save jhs/3253501 to your computer and use it in GitHub Desktop.
Iris-Redis example
if(!process.env.redis_pass)
return console.error('Run this first: export redis_pass=<your password>')
var redis = require('iris-redis') // npm install iris-redis first, of course.
var client = redis.createClient(6379, 'redis.pouch.iriscouch.com')
client.auth(process.env.redis_pass)
client.on("ready", function() {
console.log('Connected %s at %s:%d', client.host, client.stream.remoteAddress, client.stream.remotePort)
client.iris_config(function(er, config) {
if(er) throw er
console.log("Server config: %j", config)
client.iris_upgrade(function(er, new_client) {
if(er) throw er
console.log('Upgraded: %s:%d', new_client.stream.remoteAddress, new_client.stream.remotePort)
new_client.ping(function(er, pong) {
if(er) throw er
console.log('%s: confirmed direct connection', pong)
new_client.quit()
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment