GithubHelp home page GithubHelp logo

iris-redis's Introduction

Redis on Iris Couch

iris-redis is a very simple wrapper, 100% compatible with the Node.js redis package. It simplifies connecting, and helps to see metadata about your server.

iris-redis is in the npm registry:

npm install iris-redis

Example

var redis = require('iris-redis')
var client = redis.createClient(6379, "redis.example.iriscouch.com")
client.auth("s3cret")

client.on("ready", function() {
  // Done! Hey, I said it was 100% compatible.
  client.iris_config(function(er, config) {
    if(er) throw er

    console.log("Got my server config: %j", config)
    client.quit()
  })
})

The output looks like this:

Got my server config:
{ '_config:datacenter': 'sj01.softlayer',
  '_config:server': 'example',
  '_config:max_memory': '20mb',
  '_config:ip': '10.55.80.194',
  '_config:port': '17162' }

Easy AUTH command

Iris Couch requires an AUTH command in the format your_hostname.redis.irstack.com:your_password. To save you some trouble, the iris-redis package prepends the hostname in its .auth() wrapper.

In other words, if you run this: client.auth("s3cret")

then iris-redis will convert that to this: client.auth("redis.example.iriscouch.com:s3cret")

Automatic authentication.

Since authentication is mandatory on Iris Couch, you can provide the "auth" key in the options.

var client = redis.createClient(6379, "redis.example.iriscouch.com", {auth: "s3cret"})

Upgrading to a direct connection

Iris Couch uses a reverse proxy—the same battle-hardened proxy that runs CouchDB. Unfortunately, this adds latency to Redis.

If you are in the right data center, you can connect directly to your server's IP address and port. The information is in the _config/* keys, or there is a convenience function.

client.iris_upgrade(function(er, new_client) {
  if(er) throw er

  // Hooray! This is a direct LAN connection to the back-end. Note, the original client already quit().
  new_client.set("happy", "true")
  new_client.quit()
})

License

Apache 2.0

iris-redis's People

Contributors

jhs avatar

Stargazers

Andrew Henderson avatar node-migrator-bot avatar Cory Armbrecht avatar Gabriel Baciu avatar Alex avatar

Watchers

James Cloos avatar  avatar

iris-redis's Issues

Doesn't seem compatible with redis

// Put your info here
var HOST = 'host';
var PORT = 6379;
var PASS = 'pass';
var STANDARD_REDIS = true;

var redis = STANDARD_REDIS ? require('redis') : require('iris-redis');

// show debug output (not supported by iris)
redis.debug_mode = true;

var client = redis.createClient(PORT, HOST);
client.auth(PASS);

client.on("ready", function() {
  console.log('ready');
  process.exit();
});

When STANDARD_REDIS = true (using version 0.7.1 here), this fails with:

aving auth as {{ our auth }}
Stream connected nodejitsudb4187025225.redis.irstack.com:6379 id 1
Using default parser module: javascript
Sending auth to nodejitsudb4187025225.redis.irstack.com:6379 id 1
send nodejitsudb4187025225.redis.irstack.com:6379 id 1: *2
$4
auth
$32
{{ our auth }}

send_command buffered_writes: 0  should_buffer: false
net read nodejitsudb4187025225.redis.irstack.com:6379 id 1: -ERR operation not permitted


/Users/hunter/work/canary/node_modules/redis/index.js:450
                throw callback_err;
                      ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.