parse-redis-url-simple is a focused JavaScript utility designed for parsing Redis connection URLs, including complex scenarios like Redis Sentinel configurations. It provides a simple, direct API for converting various URL formats into structured objects containing host, port, database, and password. Unlike several unmaintained or production-unsuitable prior art libraries mentioned in its README, this package aims to offer a robust and reliable solution for production environments. Currently at version 1.0.2, it appears to follow a stable release cadence typical of utility libraries, with updates primarily for bug fixes or minor enhancements. A key differentiator is its explicit support for ioredis-compatible Sentinel URLs, addressing a common need in distributed Redis setups.
npm install parse-redis-url-simpleVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse various Redis URL formats, including single instances, multiple comma-separated instances, URLs with passwords, and Redis Sentinel configurations using the `parseRedisUrl` function.
Ensure `parseRedisUrl('host1:port,host2:port', true)` is used for Sentinel setups, rather than attempting to embed a sentinel flag within the URL string itself.If Redis username authentication is critical, this library might not be sufficient on its own. Ensure your Redis client handles username separately if required, or confirm your Redis setup only relies on password authentication.
Always provide a complete and explicit Redis URL string to avoid relying on implicit defaults, especially in production environments where explicit configuration is preferred.
For ESM, use `import parseRedisUrl from 'parse-redis-url-simple';`. For CommonJS, use `const parseRedisUrl = require('parse-redis-url-simple');`.Ensure the call is `parseRedisUrl('host1:port,host2:port', true)` to correctly parse and return an array of multiple sentinel host objects.No dependency data recorded yet.