JSPM

parse-redis-url-simple

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 138917
  • Score
    100M100P100Q175086F
  • License ISC

Simple parser for redis url

Package Exports

  • parse-redis-url-simple

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-redis-url-simple) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

parse-redis-url-simple parsing redis urls with sentinel support

Build Status npm version

Simple parser for redis url. It supports sentinel urls for ioredis

Module usage

const parseRedisUrl = require('parse-redis-url-simple')

// Defaults to localhost:6379/0
parseRedisUrl()
//=> [{host: 'localhost', port: 6379, database: '0', password: undefined}]
parseRedisUrl('redis://')
//=> [{host: 'localhost', port: 6379, database: '0', password: undefined}]

// But you can change databases by adding a path
parseRedisUrl('redis:///1')
//=> [{host: 'localhost', port: 6379, database: '1', password: undefined}]

// Many instances
parseRedisUrl('redis://barhost.com:39143/,redis://foohost.com:39143/')
//=> [{host: 'barhost.com', port: 39143, database: '0', password: undefined}, 
//=>  {host: 'foohost.com', port: 39143, database: '0', password: undefined}]

// And even add passwords
parseRedisUrl('redis://n9y25ah7@foohost.com:39143/')
parseRedisUrl('redis://:n9y25ah7@foohost.com:39143/')
//=> [{host: 'foohost.com', port: 39143, database: '0', password: 'n9y25ah7'}]

// If you add a username, it's ignored
parseRedisUrl('redis://user:hunter2@foohost.com:39143/')
//=> [{host: 'foohost.com', port: 39143, database: '0', password: 'hunter2'}]

// For sentinels: just set parameter sentinel=true
parseRedisUrl('barhost.com:39143,foohost.com:39143,foobarhost.com:39143', sentinel=true)
//=> [{host: 'barhost.com', port: 39143},{host: 'foohost.com', port: 39143},{host: 'foobarhost.com', port: 39143}]

More examples

Could be found here:

  • tests: the set of unit tests.

Prior art

All implementations

are not maintained or not for production use. It looks they were implemented only for testing purposes. Usually there have been more than one redis server in production. Moreover sometimes it is implemented via cluster or sentinel.