Registry / database / parse-redis-url

parse-redis-url

JSON →
library0.0.2jsnpmunverified

A small utility (v0.0.2, last updated in 2014) for parsing redis:// URLs into node_redis configuration objects. Unlike general URL parsers, this is tailored specifically to node_redis, handling host, port, password, and database number. Also provides a convenience method to create a node_redis client directly from the URL. No releases in years, likely unmaintained. Minimal dependencies, but requires the redis package at usage time.

npm install parse-redis-url
INSTALL
IMPORT
SIG · PARSE-REDIS-URL
P
parse-redis-url
databasejavascriptv0.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
var parseRedisUrl = require('parse-redis-url')(redis);
const parseRedisUrl = require('parse-redis-url');
The module exports a function that must be called with the node_redis module; doing otherwise will throw an error.
createClient
parseRedisUrl.createClient(url, callback);
Creates a node_redis client from the parsed URL. Note: only works after calling the factory with the redis module.
parse
var options = parseRedisUrl.parse(url);
Returns an object with host, port, password, database. Note: username is dropped as Redis doesn't use it.

Shows how to require, initialize with the redis module, parse a Redis URL, and create a client.

var redis = require('redis'); var parseRedisUrl = require('parse-redis-url')(redis); var url = 'redis://dummy:password@example.com:5555/42'; parseRedisUrl.createClient(url, function(err, client) { if (err) { console.error('Failed to create client:', err); return; } client.set('key', 'value', function(err) { if (err) console.error(err); client.quit(); }); });
Debug
Known issues
gotchaMust pass the redis module to the factory function; otherwise parseRedisUrl is not a function or methods are undefined.
fix
Require the redis module and call require('parse-redis-url')(redis) before using the returned object.
affects: >=0.0.1
deprecatedPackage is no longer maintained; last published in 2014. May not work with newer versions of node_redis or Node.js.
fix
Consider using ioredis's built-in Redis URL support or a more modern alternative like redis-url-parser.
affects: >=0.0.1
gotchaThe createClient callback is required; calling without a callback will throw an error.
fix
Always provide a callback function when using createClient.
affects: >=0.0.1
breakingNode.js versions that do not support the 'url' module natively may cause parse failures.
fix
Use Node.js 0.10 or later.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: parseRedisUrl is not a function
The module exports a factory that must be invoked with the redis module.
fix
var parseRedisUrl = require('parse-redis-url')(redis);
TypeError: parseRedisUrl.createClient is not a function
parseRedisUrl is the factory result, but the factory was not called correctly.
fix
Ensure you call require('parse-redis-url')(redis) and capture the returned object.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
parse-redis-url — npm install parse-redis-url · libregistry