Git Product home page Git Product logo

redis-url's Introduction

redis-url

Connect to redis using a fully-qualified URL.

Usage

// Defaults to process.env.REDIS_URL or redis://localhost:6379
var redis = require('redis-url').connect();

// Or you can specify a URL
var redis = require('redis-url').connect(process.env.SOMEREDIS_URL);

The module also exposes a parse function you can use to extract parts of a redis URL. It behaves similarly to node's url.parse, but adds two extra properties: password and database.

This feature comes in handy when using redis-backed tools that don't accept a fully-qualified URL, such as Hapi's catbox-redis.

require("redis-url").parse('redis://:[email protected]:1234/9?foo=bar&baz=qux')

{
  protocol: 'redis:',
  slashes: true,
  auth: ':secrets',
  host: 'example.com:1234',
  port: '1234',
  hostname: 'example.com',
  hash: null,
  search: '?foo=bar&baz=qux',
  query: { foo: 'bar', baz: 'qux' },
  pathname: '/9',
  path: '9',
  href: 'redis://:[email protected]:1234/9?foo=bar&baz=qux',
  password: 'secrets',
  database: '9'
}

URL format

redis://[:password@]host[:port][/db-number][?option=value]

db-number is a non-negative decimal integer

See the IANA registration for more details.

Test

redis-server&
npm install
npm test

License

MIT

redis-url's People

Contributors

zeke avatar ddollar avatar rlidwka avatar cvrebert avatar kudos avatar tikotzky avatar sugyan avatar

Watchers

James Cloos avatar

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.